{
  "name": "Find companies with Prosp and add them to a Google Sheet",
  "nodes": [
    {
      "parameters": {},
      "id": "7b703a2f-c3e7-5a7c-b62b-47c0a1ffa4d2",
      "name": "Start by hand",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        420
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 8
            }
          ]
        }
      },
      "id": "c95173b6-248f-5bea-926e-b9d5d80188d4",
      "name": "Or start on a schedule (off)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        600
      ],
      "disabled": true
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "6ae6646d-3edb-5a1f-8e93-23880e191ac9",
              "name": "request",
              "value": "Find food and beverage producers in Czechia that run their own production and bottling lines and buy packaging",
              "type": "string"
            },
            {
              "id": "6846eeb5-28c5-58fb-b5f5-2b501afa8cb9",
              "name": "countries",
              "value": "Czechia",
              "type": "string"
            },
            {
              "id": "2596f7a8-a498-50b4-a9b4-e0a2e0c6003d",
              "name": "company_sizes",
              "value": "small,medium",
              "type": "string"
            },
            {
              "id": "6cadfc29-8a27-55d7-b26f-2bcbb0a0c02b",
              "name": "max_companies",
              "value": 25,
              "type": "number"
            },
            {
              "id": "252ca1c4-ceb1-524b-b87d-e09fdaf1b4ff",
              "name": "run_even_if_few_new",
              "value": false,
              "type": "boolean"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "id": "b14c3f36-dbd6-5c01-8e39-3ef2378c86d2",
      "name": "Describe the companies you want",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        260,
        420
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "924bc2cd-91dd-5982-a8ad-69a05f44bb3f",
              "name": "run_key",
              "value": "={{ 'prosp-n8n-' + $now.toMillis() }}",
              "type": "string"
            },
            {
              "id": "b4f63fcb-0b23-575f-807b-c292fd8a07dd",
              "name": "body_json",
              "value": "={{ (() => { const b = { query: $json.request, maxResults: Number($json.max_companies) || 50 }; const list = (s) => String(s || '').split(',').map(x => x.trim()).filter(Boolean); if (list($json.countries).length) b.locations = list($json.countries); if (list($json.company_sizes).length) b.company_sizes = list($json.company_sizes); if ($json.run_even_if_few_new === true) b.acknowledge_low_yield = true; return JSON.stringify(b); })() }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "id": "fc802518-55b2-5cd4-99ff-681725ead742",
      "name": "Build the request",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        500,
        420
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.prosp.cc/api/v1/discoveries",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "X-Idempotency-Key",
              "value": "={{ $('Build the request').first().json.run_key }}"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ $('Build the request').first().json.body_json }}",
        "options": {
          "response": {
            "response": {
              "fullResponse": true,
              "neverError": true
            }
          },
          "timeout": 60000
        }
      },
      "id": "82a71079-4f4f-5d1c-a55a-fec938138412",
      "name": "Start the search (costs 100 credits)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        760,
        420
      ]
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "82145535-8b2b-5b3b-a544-acdcb89ff6ec",
                    "leftValue": "={{ $json.statusCode }}",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "rightValue": 200
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Started"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "253d26bc-ee8a-5801-adb3-3830478e515f",
                    "leftValue": "={{ $json.statusCode === 409 && $json.body.status === 'duplicate_running_job' }}",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Same search already running"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "ac6001e0-11e6-577a-8f7c-ba9d52e0d285",
                    "leftValue": "={{ $json.statusCode }}",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "rightValue": 409
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Held, nothing charged"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "17ef2eb1-7f08-5912-a7fb-db9b6e5fa4c8",
                    "leftValue": "={{ $json.statusCode }}",
                    "operator": {
                      "type": "number",
                      "operation": "equals"
                    },
                    "rightValue": 429
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Too many requests"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Other problem"
        }
      },
      "id": "3f2ff47e-4200-5630-9156-19b65f3f6b5a",
      "name": "What did Prosp answer to the start?",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        1020,
        420
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e1a86904-568f-5145-84a8-e0dc2b369ff8",
              "name": "job_id",
              "value": "={{ $json.body.jobId || $json.body.running_job_id }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "id": "cc812deb-28d4-5b22-a75c-022ee6529bfc",
      "name": "Keep the search id",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1300,
        200
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Prosp held this search and charged nothing (HTTP 409: ' + ($json.body.status || 'warning') + '). ' + ($json.body.message || '') + ' To run it anyway, set run_even_if_few_new to true in the step \"Describe the companies you want\" and run again.' }}"
      },
      "id": "dc04e00d-f6fe-5e09-8ff4-166e6fee250b",
      "name": "Stop: held before the start, nothing charged",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1300,
        420
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "464a31fe-92d9-54de-add3-918d4ce6ad9b",
              "leftValue": "={{ $runIndex }}",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "rightValue": 4
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "9e7c8897-d307-5d27-aeed-16e95800cf2a",
      "name": "Retries left for the start?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        1300,
        620
      ]
    },
    {
      "parameters": {
        "amount": "={{ Math.min(Math.max(parseInt($json.headers && $json.headers['retry-after']) || 60, 5), 300) }}",
        "unit": "seconds"
      },
      "id": "1f4db3ac-4a9e-53ae-978d-8e3c11c2abac",
      "name": "Wait, then retry the start",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1540,
        560
      ],
      "webhookId": "04c2ad27-19cb-52d1-8065-ff2cb36b7a6a"
    },
    {
      "parameters": {
        "errorMessage": "Prosp answered 429 (too many requests, or too many searches running at once) four times in a row. The search was not started and nothing was charged. Wait a few minutes and run again."
      },
      "id": "5bb8a818-eac6-59f4-baf8-fa07cc55bcdf",
      "name": "Stop: still too many requests after 4 retries",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1540,
        700
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Prosp refused the start (HTTP ' + $json.statusCode + ': ' + (($json.body && $json.body.error) || 'error') + '). ' + (($json.body && $json.body.message) ? String($json.body.message).replace(/[.\\s]+$/, '') + '. ' : '') + '401 means the credential was rejected, 402 means not enough credits, 400 means the request was malformed. Nothing was started.' }}"
      },
      "id": "fe7bb577-2703-5033-bd63-f35dd732b4fa",
      "name": "Stop: Prosp refused the start",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1300,
        820
      ]
    },
    {
      "parameters": {
        "amount": "={{ Math.min(20 + 20 * $runIndex, 120) }}",
        "unit": "seconds"
      },
      "id": "329bac61-1b8e-5391-9e8b-7d5e9912ae59",
      "name": "Wait before checking",
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        1560,
        200
      ],
      "webhookId": "a4a56b6b-3f56-5a0a-9d70-96679990b287"
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ 'https://api.prosp.cc/api/v1/discoveries/' + $('Keep the search id').first().json.job_id }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "options": {
          "timeout": 60000
        }
      },
      "id": "c53e15de-6247-5b1b-bb31-acc2f2884f79",
      "name": "Check the search",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1800,
        200
      ],
      "retryOnFail": true,
      "maxTries": 4,
      "waitBetweenTries": 5000,
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "f0808b50-a746-583a-b766-b70b467d7103",
                    "leftValue": "={{ ['completed','exhausted','cancelled'].includes($json.status) }}",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Finished"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "c473bcf2-2fda-5142-a658-96d0644d566b",
                    "leftValue": "={{ $json.status === 'failed' }}",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "Failed"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Still running"
        }
      },
      "id": "3108056c-c0f1-5524-a542-b645bb7eb0c1",
      "name": "How is the search going?",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        2060,
        200
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Prosp reports search ' + $json.jobId + ' as failed. Per the Prosp pricing page, a search that fails before delivering anything is credited back; check the credit ledger in the Prosp bot.' }}"
      },
      "id": "37ab8899-c8d9-5cda-b619-b9e70b90758f",
      "name": "Stop: the search failed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        2320,
        420
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Checking the search failed: ' + ($json.error && $json.error.message ? $json.error.message : JSON.stringify($json.error)) + '. The search itself may still be running; its id is ' + $('Keep the search id').first().json.job_id + '.' }}"
      },
      "id": "e43d0e34-dce2-589f-912b-641835a65d7a",
      "name": "Stop: the status check failed",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        2060,
        420
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "43e86e5a-05f2-576e-adb7-927e2a0953bf",
              "leftValue": "={{ $runIndex }}",
              "operator": {
                "type": "number",
                "operation": "lt"
              },
              "rightValue": 29
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c302ec41-6a3e-5da7-845a-c114ebbb62bf",
      "name": "Checks left?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        2320,
        40
      ]
    },
    {
      "parameters": {
        "errorMessage": "={{ 'Search ' + $('Keep the search id').first().json.job_id + ' was still running after 30 checks (about an hour). It is not cancelled and keeps running at Prosp. Read its companies later with GET /api/v1/discoveries/{id}/prospects, or cancel it with POST /mcp/jobs/{id}/cancel.' }}"
      },
      "id": "6d9baab8-a6b7-528b-b6f2-16d62457a244",
      "name": "Stop: still running after 30 checks",
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        2560,
        120
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "4261a57c-2d2d-5b51-a97f-2c9809293495",
              "name": "search_id",
              "value": "={{ $json.jobId }}",
              "type": "string"
            },
            {
              "id": "87a8c9c3-2df2-5164-aa44-255879fbdc5f",
              "name": "search_status",
              "value": "={{ $json.status }}",
              "type": "string"
            },
            {
              "id": "a05b3db1-abf1-56a2-b823-047796d9c2f0",
              "name": "search_ended",
              "value": "={{ ($json.result && $json.result.terminal_reason) || $json.status }}",
              "type": "string"
            },
            {
              "id": "b94bfa44-017b-5bdc-977a-e01ce5e2583a",
              "name": "credits_returned",
              "value": "={{ ($json.result && $json.result.credits_refunded) || 0 }}",
              "type": "number"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "id": "cdb4ce38-baf7-504b-94e3-dda43a1f8ffd",
      "name": "Note how the search ended",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2320,
        200
      ]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "={{ 'https://api.prosp.cc/api/v1/discoveries/' + $('Keep the search id').first().json.job_id + '/prospects' }}",
        "authentication": "genericCredentialType",
        "genericAuthType": "oAuth2Api",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "200"
            }
          ]
        },
        "options": {
          "pagination": {
            "pagination": {
              "paginationMode": "updateAParameterInEachRequest",
              "parameters": {
                "parameters": [
                  {
                    "type": "qs",
                    "name": "offset",
                    "value": "={{ $pageCount * 200 }}"
                  }
                ]
              },
              "paginationCompleteWhen": "other",
              "completeExpression": "={{ !$response.body.prospects || $response.body.prospects.length < 200 }}",
              "limitPagesFetched": true,
              "maxRequests": 25,
              "requestInterval": 700
            }
          },
          "timeout": 60000
        }
      },
      "id": "bb121a6d-c057-5437-8165-130524cb648f",
      "name": "Read the companies",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2560,
        320
      ],
      "retryOnFail": true,
      "maxTries": 4,
      "waitBetweenTries": 5000
    },
    {
      "parameters": {
        "fieldToSplitOut": "prospects",
        "options": {}
      },
      "id": "a6db8535-ed0f-5fda-8847-637920de6314",
      "name": "One row per company",
      "type": "n8n-nodes-base.splitOut",
      "typeVersion": 1,
      "position": [
        2800,
        320
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1b4c554b-f3b9-5b9f-9cdd-9f644ef4ba6b",
              "name": "name",
              "value": "={{ $json.name || '' }}",
              "type": "string"
            },
            {
              "id": "7bbd5db4-fe3f-5768-937a-14186a6cee85",
              "name": "website",
              "value": "={{ $json.domain ? 'https://' + $json.domain : '' }}",
              "type": "string"
            },
            {
              "id": "179cdb56-de38-56c3-ba9c-daf2d5a65275",
              "name": "domain",
              "value": "={{ $json.domain || '' }}",
              "type": "string"
            },
            {
              "id": "9a935b51-b087-57ef-81e7-1e5705f9a088",
              "name": "country",
              "value": "={{ $json.country || '' }}",
              "type": "string"
            },
            {
              "id": "98ee0c50-0cd2-56ec-b070-9ddb35935859",
              "name": "city",
              "value": "={{ $json.city || '' }}",
              "type": "string"
            },
            {
              "id": "a9b2178f-b075-5d9a-b930-417690489fbb",
              "name": "size",
              "value": "={{ $json.company_size || '' }}",
              "type": "string"
            },
            {
              "id": "17b3fbd5-1eb4-50ca-9eee-4e00ca4127b4",
              "name": "employees",
              "value": "={{ $json.employee_count || '' }}",
              "type": "string"
            },
            {
              "id": "d8b99dd3-c6d2-565d-af0f-201728121b4f",
              "name": "registration_number",
              "value": "={{ $json.registry_id || '' }}",
              "type": "string"
            },
            {
              "id": "d7321873-fa2c-509b-b9f1-6c57abda9c75",
              "name": "company_emails",
              "value": "={{ ($json.company_emails || []).join('; ') }}",
              "type": "string"
            },
            {
              "id": "d7fd6a52-b449-519e-8bdf-55d0535d67e4",
              "name": "company_phones",
              "value": "={{ ($json.phones || []).join('; ') }}",
              "type": "string"
            },
            {
              "id": "a5accf2a-ca22-5a75-9013-dcfdef261245",
              "name": "contact_name",
              "value": "={{ (($json.contacts || []).find(c => c.email) || ($json.contacts || [])[0] || {}).name || '' }}",
              "type": "string"
            },
            {
              "id": "a3d7be1f-6607-55ed-888e-eaa8de489ff0",
              "name": "contact_position",
              "value": "={{ (($json.contacts || []).find(c => c.email) || ($json.contacts || [])[0] || {}).position || '' }}",
              "type": "string"
            },
            {
              "id": "d8f16fdd-65f1-5969-a0f1-85b9acf6d06d",
              "name": "contact_email",
              "value": "={{ (($json.contacts || []).find(c => c.email) || ($json.contacts || [])[0] || {}).email || '' }}",
              "type": "string"
            },
            {
              "id": "03f63d0b-cc86-521a-a29a-52ec085a4362",
              "name": "contact_email_inferred",
              "value": "={{ !!(($json.contacts || []).find(c => c.email) || ($json.contacts || [])[0] || {}).email_source }}",
              "type": "string"
            },
            {
              "id": "20953b4a-c817-57d0-ab27-925b668b6843",
              "name": "contact_phone",
              "value": "={{ (($json.contacts || []).find(c => c.email) || ($json.contacts || [])[0] || {}).phone || '' }}",
              "type": "string"
            },
            {
              "id": "45cd78e9-6d07-5f4b-b97f-ffb264311650",
              "name": "contact_linkedin",
              "value": "={{ (($json.contacts || []).find(c => c.email) || ($json.contacts || [])[0] || {}).linkedin_url || '' }}",
              "type": "string"
            },
            {
              "id": "166fb594-b637-56ed-beef-579ba0a1a00d",
              "name": "emails_count",
              "value": "={{ ($json.company_emails || []).length + ($json.contacts || []).filter(c => c.email).length }}",
              "type": "string"
            },
            {
              "id": "4cc59de6-80d7-5e9d-8043-ed5e005d7ca8",
              "name": "phones_count",
              "value": "={{ ($json.phones || []).length + ($json.contacts || []).filter(c => c.phone).length }}",
              "type": "string"
            },
            {
              "id": "bc6c90f3-f0f1-5e1f-80e6-82540a4de99c",
              "name": "contacts_count",
              "value": "={{ ($json.contacts || []).length }}",
              "type": "string"
            },
            {
              "id": "4261a57c-2d2d-5b51-a97f-2c9809293495",
              "name": "search_id",
              "value": "={{ $('Note how the search ended').first().json.search_id }}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "id": "aecf6448-e502-569d-8b81-082416bf100d",
      "name": "Pick the columns for the sheet",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        3040,
        320
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "249bc496-0525-5779-9d03-97fd6c63b3a4",
      "name": "Add a row to your Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        3300,
        260
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://your-crm.example.com/api/companies",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json) }}",
        "options": {}
      },
      "id": "e730349e-33c3-5972-b027-2f0e48add9d7",
      "name": "Send to your CRM instead (example, off)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3300,
        460
      ],
      "disabled": true
    },
    {
      "parameters": {
        "content": "## Find companies with Prosp and add them to a Google Sheet\n### How it works\nYou describe the companies you want in plain words. The workflow starts one Prosp search, waits until it ends, reads the companies it found, and adds one row per company to a Google Sheet. Each row has name, website, country, city, size, registration number, the company's public e-mails and phones, and the best contact Prosp found.\nA search usually takes minutes; some take up to about an hour. The workflow checks every 20 to 120 seconds and stops after 30 checks.\n### Setup\n1. You need a Prosp account: open the Prosp Telegram bot (prosp.cc), buy a credit pack, send /credentials.\n2. In n8n create one credential of type OAuth2 API: grant type Client Credentials, access token URL https://prosp-mcp-641053169627.auth.eu-central-1.amazoncognito.com/oauth2/token (also in the OpenAPI spec at prosp.cc/docs), scope mcp/execute, authentication Header, your client id and secret. Select it on the three Prosp HTTP steps.\n3. Pick your Google Sheet in the last step. Row 1 must hold the column names.\n4. Edit the first step, then run by hand.\n**Cost: every run starts one paid search, 100 credits.** A search that ends short is credited back as the Prosp pricing page describes.\n### Customization\nSwitch on the CRM step to send rows to your own CRM.",
        "height": 560,
        "width": 700
      },
      "id": "d5db4e16-aca8-5cb8-a976-4ac0d6e145dd",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -60,
        -260
      ]
    },
    {
      "parameters": {
        "content": "## Paid step\n100 credits per run. A schedule trigger repeats it.",
        "height": 70,
        "width": 240,
        "color": 3
      },
      "id": "43cce685-b340-565d-85ec-a8705ab8ace2",
      "name": "Warning: paid step",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        740,
        330
      ]
    },
    {
      "parameters": {
        "content": "## 1. Describe\nYour request in one sentence. Countries and sizes are optional.",
        "height": 110,
        "width": 220,
        "color": 7
      },
      "id": "ec009a43-24c6-50ea-aedd-04d853d9e960",
      "name": "Section: describe",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        240,
        330
      ]
    },
    {
      "parameters": {
        "content": "## 2. Start the search\nOne retry-safe call. Prosp answers 409 (held, nothing charged) or 429 (wait and retry).",
        "height": 70,
        "width": 520,
        "color": 7
      },
      "id": "9d69b0d2-3936-503b-ad1d-6f55759f9e76",
      "name": "Section: start",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1000,
        560
      ]
    },
    {
      "parameters": {
        "content": "## 3. Wait until it ends\nChecks every 20 to 120 seconds, at most 30 times.",
        "height": 90,
        "width": 240,
        "color": 7
      },
      "id": "2144c221-e661-523b-96d2-a96d54938ff8",
      "name": "Section: wait",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1540,
        60
      ]
    },
    {
      "parameters": {
        "content": "## 4. Read the companies\n200 per page. A search that ends short is still read.",
        "height": 90,
        "width": 240,
        "color": 7
      },
      "id": "c45b8f63-b899-56cc-90b5-b81477000251",
      "name": "Section: read",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        2540,
        230
      ]
    },
    {
      "parameters": {
        "content": "## 5. Write the rows\nSheet columns match the field names. The CRM step is an off example.",
        "height": 90,
        "width": 420,
        "color": 7
      },
      "id": "30000ed5-d95e-5e3f-80e5-8b6ab7e082f1",
      "name": "Section: write",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        3020,
        160
      ]
    }
  ],
  "connections": {
    "Start by hand": {
      "main": [
        [
          {
            "node": "Describe the companies you want",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Or start on a schedule (off)": {
      "main": [
        [
          {
            "node": "Describe the companies you want",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Describe the companies you want": {
      "main": [
        [
          {
            "node": "Build the request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build the request": {
      "main": [
        [
          {
            "node": "Start the search (costs 100 credits)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start the search (costs 100 credits)": {
      "main": [
        [
          {
            "node": "What did Prosp answer to the start?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "What did Prosp answer to the start?": {
      "main": [
        [
          {
            "node": "Keep the search id",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Keep the search id",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: held before the start, nothing charged",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Retries left for the start?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: Prosp refused the start",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retries left for the start?": {
      "main": [
        [
          {
            "node": "Wait, then retry the start",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: still too many requests after 4 retries",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait, then retry the start": {
      "main": [
        [
          {
            "node": "Start the search (costs 100 credits)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep the search id": {
      "main": [
        [
          {
            "node": "Wait before checking",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait before checking": {
      "main": [
        [
          {
            "node": "Check the search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check the search": {
      "main": [
        [
          {
            "node": "How is the search going?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: the status check failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "How is the search going?": {
      "main": [
        [
          {
            "node": "Note how the search ended",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: the search failed",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Checks left?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Checks left?": {
      "main": [
        [
          {
            "node": "Wait before checking",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop: still running after 30 checks",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Note how the search ended": {
      "main": [
        [
          {
            "node": "Read the companies",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read the companies": {
      "main": [
        [
          {
            "node": "One row per company",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "One row per company": {
      "main": [
        [
          {
            "node": "Pick the columns for the sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pick the columns for the sheet": {
      "main": [
        [
          {
            "node": "Add a row to your Google Sheet",
            "type": "main",
            "index": 0
          },
          {
            "node": "Send to your CRM instead (example, off)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}