{
    "name": "Cornersight -> Google Sheets lead log",
    "flow": [
        {
            "id": 1,
            "module": "gateway:CustomWebHook",
            "version": 1,
            "parameters": {
                "hook": null,
                "maxResults": 1
            },
            "mapper": {},
            "metadata": {
                "designer": {
                    "x": 0,
                    "y": 0
                },
                "restore": {
                    "parameters": {
                        "hook": {
                            "label": "Cornersight webhook (click Add to create yours)",
                            "data": {
                                "editable": "true"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "hook",
                        "type": "hook:gateway-webhook",
                        "label": "Webhook",
                        "required": true
                    },
                    {
                        "name": "maxResults",
                        "type": "number",
                        "label": "Maximum number of results"
                    }
                ]
            }
        },
        {
            "id": 2,
            "module": "google-sheets:filterRows",
            "version": 2,
            "parameters": {
                "__IMTCONN__": null
            },
            "mapper": {
                "from": "drive",
                "spreadsheetId": "",
                "sheetId": "Leads",
                "includesHeaders": true,
                "tableFirstRow": "A1:Z1",
                "filter": [
                    [
                        {
                            "a": "A",
                            "b": "{{1.data.leadId}}",
                            "o": "text:equal"
                        }
                    ]
                ],
                "sortOrder": "asc",
                "limit": "1",
                "valueRenderOption": "FORMATTED_VALUE",
                "dateTimeRenderOption": "FORMATTED_STRING"
            },
            "metadata": {
                "designer": {
                    "x": 300,
                    "y": 0
                },
                "restore": {
                    "parameters": {
                        "__IMTCONN__": {
                            "label": "Connect your Google account",
                            "data": {
                                "scoped": "true",
                                "connection": "google"
                            }
                        }
                    },
                    "expect": {
                        "spreadsheetId": {
                            "mode": "chose",
                            "label": "PICK YOUR SHEET"
                        },
                        "sheetId": {
                            "mode": "chose",
                            "label": "Leads"
                        },
                        "includesHeaders": {
                            "mode": "chose",
                            "label": "Yes"
                        },
                        "tableFirstRow": {
                            "label": "A-Z"
                        },
                        "sortOrder": {
                            "mode": "chose",
                            "label": "Ascending"
                        },
                        "valueRenderOption": {
                            "mode": "chose",
                            "label": "Formatted value"
                        },
                        "dateTimeRenderOption": {
                            "mode": "chose",
                            "label": "Formatted string"
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "__IMTCONN__",
                        "type": "account:google",
                        "label": "Connection",
                        "required": true
                    }
                ]
            }
        },
        {
            "id": 3,
            "module": "builtin:BasicAggregator",
            "version": 1,
            "parameters": {
                "feeder": 2
            },
            "mapper": {
                "__ROW_NUMBER__": "{{2.`__ROW_NUMBER__`}}"
            },
            "metadata": {
                "designer": {
                    "x": 600,
                    "y": 0
                },
                "restore": {
                    "extra": {
                        "feeder": {
                            "label": "Google Sheets - Search Rows [2]"
                        },
                        "target": {
                            "label": "Custom"
                        }
                    }
                }
            }
        },
        {
            "id": 4,
            "module": "google-sheets:addRow",
            "version": 2,
            "parameters": {
                "__IMTCONN__": null
            },
            "filter": {
                "name": "New lead only (leadId not in sheet yet)",
                "conditions": [
                    [
                        {
                            "a": "{{length(3.array)}}",
                            "b": "0",
                            "o": "number:equal"
                        }
                    ]
                ]
            },
            "mapper": {
                "from": "drive",
                "mode": "select",
                "spreadsheetId": "",
                "sheetId": "Leads",
                "includesHeaders": true,
                "insertDataOption": "INSERT_ROWS",
                "valueInputOption": "USER_ENTERED",
                "insertUnformatted": false,
                "values": {
                    "0": "{{1.data.leadId}}",
                    "1": "{{1.timestamp}}",
                    "2": "{{1.data.name}}",
                    "3": "{{1.data.jobTitle}}",
                    "4": "{{1.data.companyName}}",
                    "5": "{{1.data.companyDomain}}",
                    "6": "{{1.data.companyIndustry}}",
                    "7": "{{1.data.companyStaffRange}}",
                    "8": "{{1.data.country}}",
                    "9": "{{1.data.linkedinUrl}}",
                    "10": "{{1.data.email}}",
                    "11": "{{1.data.isIcp}}",
                    "12": "{{1.data.engagementType}}",
                    "13": "{{1.data.commentText}}",
                    "14": "{{1.data.postUrl}}",
                    "15": "{{1.data.trackedProfile}}"
                }
            },
            "metadata": {
                "designer": {
                    "x": 900,
                    "y": 0
                },
                "restore": {
                    "parameters": {
                        "__IMTCONN__": {
                            "label": "Connect your Google account",
                            "data": {
                                "scoped": "true",
                                "connection": "google"
                            }
                        }
                    },
                    "expect": {
                        "from": {
                            "label": "My Drive"
                        },
                        "mode": {
                            "label": "Select from the list"
                        },
                        "spreadsheetId": {
                            "path": [
                                "PICK YOUR SHEET"
                            ]
                        },
                        "sheetId": {
                            "label": "Leads"
                        },
                        "includesHeaders": {
                            "label": "Yes",
                            "nested": [
                                {
                                    "name": "values",
                                    "label": "Values",
                                    "type": "collection",
                                    "spec": [
                                        {
                                            "name": "0",
                                            "type": "text",
                                            "label": "leadId (A)"
                                        },
                                        {
                                            "name": "1",
                                            "type": "text",
                                            "label": "detectedAt (B)"
                                        },
                                        {
                                            "name": "2",
                                            "type": "text",
                                            "label": "name (C)"
                                        },
                                        {
                                            "name": "3",
                                            "type": "text",
                                            "label": "jobTitle (D)"
                                        },
                                        {
                                            "name": "4",
                                            "type": "text",
                                            "label": "company (E)"
                                        },
                                        {
                                            "name": "5",
                                            "type": "text",
                                            "label": "companyDomain (F)"
                                        },
                                        {
                                            "name": "6",
                                            "type": "text",
                                            "label": "companyIndustry (G)"
                                        },
                                        {
                                            "name": "7",
                                            "type": "text",
                                            "label": "companyStaffRange (H)"
                                        },
                                        {
                                            "name": "8",
                                            "type": "text",
                                            "label": "country (I)"
                                        },
                                        {
                                            "name": "9",
                                            "type": "text",
                                            "label": "linkedinUrl (J)"
                                        },
                                        {
                                            "name": "10",
                                            "type": "text",
                                            "label": "email (K)"
                                        },
                                        {
                                            "name": "11",
                                            "type": "text",
                                            "label": "isIcp (L)"
                                        },
                                        {
                                            "name": "12",
                                            "type": "text",
                                            "label": "engagementType (M)"
                                        },
                                        {
                                            "name": "13",
                                            "type": "text",
                                            "label": "commentText (N)"
                                        },
                                        {
                                            "name": "14",
                                            "type": "text",
                                            "label": "postUrl (O)"
                                        },
                                        {
                                            "name": "15",
                                            "type": "text",
                                            "label": "source (P)"
                                        }
                                    ]
                                }
                            ]
                        },
                        "insertDataOption": {
                            "mode": "chose",
                            "label": "Insert rows"
                        },
                        "valueInputOption": {
                            "mode": "chose",
                            "label": "User entered"
                        },
                        "insertUnformatted": {
                            "mode": "chose"
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "__IMTCONN__",
                        "type": "account:google",
                        "label": "Connection",
                        "required": true
                    }
                ]
            }
        }
    ],
    "metadata": {
        "instant": true,
        "version": 1,
        "scenario": {
            "roundtrips": 1,
            "maxErrors": 3,
            "autoCommit": true,
            "autoCommitTriggerLast": true,
            "sequential": false,
            "confidential": false,
            "dataloss": false,
            "dlq": false,
            "freshVariables": false
        },
        "designer": {
            "orphans": [],
            "notes": [
                {
                    "id": 1,
                    "text": "Cornersight -> Google Sheets lead log.\n1. Click this webhook, click Add, save, copy the URL.\n2. Paste the URL in Cornersight: source -> webhook settings.\n3. Run once, then send a test lead so Make learns the fields.\n4. Google Sheet: tab named Leads, header row in A1: leadId, detectedAt, name, jobTitle, company, companyDomain, companyIndustry, companyStaffRange, country, linkedinUrl, email, isIcp, engagementType, commentText, postUrl, source.\n5. In both Google Sheets modules: connect Google and pick your Sheet.\nA new row is added only if the leadId is not in column A yet, so retries never make duplicates.",
                    "filter": false
                }
            ]
        },
        "zone": "us1.make.com"
    }
}
