diff --git a/modules/A1-lead-enrich-pipeline/workflows/lead-actions-example.json b/modules/A1-lead-enrich-pipeline/workflows/lead-actions-example.json new file mode 100644 index 0000000..4993d96 --- /dev/null +++ b/modules/A1-lead-enrich-pipeline/workflows/lead-actions-example.json @@ -0,0 +1,331 @@ +{ + "name": "Lead Actions Example", + "nodes": [ + { + "id": "f1a2b3c4-d5e6-7890-abcd-ef1234567890", + "name": "Execute Workflow Trigger", + "type": "n8n-nodes-base.executeWorkflowTrigger", + "typeVersion": 1.1, + "position": [0, 300], + "parameters": {} + }, + { + "id": "a2b3c4d5-e6f7-8901-bcde-f23456789012", + "name": "Grade Router", + "type": "n8n-nodes-base.switch", + "typeVersion": 3.2, + "position": [300, 300], + "parameters": { + "rules": { + "values": [ + { + "conditions": { + "conditions": [ + { + "id": "c3d4e5f6-a7b8-9012-cdef-345678901234", + "leftValue": "={{ $json.grading.profile_grade }}", + "rightValue": "Full Profile", + "operator": { + "type": "string", + "operation": "equals" + } + } + ] + } + }, + { + "conditions": { + "conditions": [ + { + "id": "d4e5f6a7-b8c9-0123-defa-456789012345", + "leftValue": "={{ $json.grading.profile_grade }}", + "rightValue": "Partial Profile", + "operator": { + "type": "string", + "operation": "equals" + } + } + ] + } + }, + { + "conditions": { + "conditions": [ + { + "id": "e5f6a7b8-c9d0-1234-efab-567890123456", + "leftValue": "={{ $json.grading.profile_grade }}", + "rightValue": "Limited", + "operator": { + "type": "string", + "operation": "equals" + } + } + ] + } + } + ] + }, + "options": { + "fallbackOutput": "extra" + } + } + }, + { + "id": "b3c4d5e6-f7a8-9012-bcde-678901234567", + "name": "HubSpot Upsert", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [600, 100], + "continueOnFail": true, + "parameters": { + "method": "POST", + "url": "https://api.hubapi.com/crm/v3/objects/contacts/batch/upsert", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Content-Type", + "value": "application/json" + }, + { + "name": "Authorization", + "value": "=Bearer {{ $env.HUBSPOT_PRIVATE_APP_TOKEN }}" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ JSON.stringify({ inputs: [{ idProperty: \"email\", id: $json.lead.email, properties: { firstname: $json.lead.first_name, lastname: $json.lead.last_name, company: $json.enrichment.organisation.name || \"\", jobtitle: $json.enrichment.person.title || \"\", website: $json.enrichment.organisation.website_url || \"\", city: $json.enrichment.person.city || \"\", country: $json.enrichment.person.country || \"\", lifecyclestage: \"lead\" } }] }) }}" + } + }, + { + "id": "c4d5e6f7-a8b9-0123-cdef-789012345678", + "name": "Slack Notification", + "type": "n8n-nodes-base.httpRequest", + "typeVersion": 4.2, + "position": [600, 300], + "continueOnFail": true, + "parameters": { + "method": "POST", + "url": "https://slack.com/api/chat.postMessage", + "sendHeaders": true, + "headerParameters": { + "parameters": [ + { + "name": "Content-Type", + "value": "application/json" + }, + { + "name": "Authorization", + "value": "=Bearer {{ $env.SLACK_BOT_TOKEN }}" + } + ] + }, + "sendBody": true, + "specifyBody": "json", + "jsonBody": "={{ JSON.stringify({ channel: \"#leads\", text: \"*New Lead \\u2014 \" + $json.grading.profile_grade + \"*\\nName: \" + ($json.lead.first_name || \"\") + \" \" + ($json.lead.last_name || \"\") + \"\\nEmail: \" + $json.lead.email + \"\\nCompany: \" + ($json.enrichment.organisation.name || \"Unknown\") + \"\\nTitle: \" + ($json.enrichment.person.title || \"Unknown\") + \"\\nSource: \" + ($json.lead.source || \"unknown\") + ($json.enrichment.credits_low ? \"\\n\\u26a0\\ufe0f Apollo credits running low!\" : \"\") }) }}" + } + }, + { + "id": "d5e6f7a8-b9c0-1234-defa-890123456789", + "name": "Welcome Email", + "type": "n8n-nodes-base.emailSend", + "typeVersion": 2.1, + "position": [600, 500], + "continueOnFail": true, + "credentials": { + "smtp": { + "id": "XU85XBahrbhS0122", + "name": "CORBEL Email SMTP" + } + }, + "parameters": { + "fromEmail": "jake@corbel.consulting", + "toEmail": "={{ $json.lead.email }}", + "subject": "Thanks for getting in touch", + "emailFormat": "html", + "html": "
\n

Hi {{ $json.lead.first_name || 'there' }},

\n

Thanks for getting in touch. We have received your details and will be in contact shortly.

\n

If you have any questions in the meantime, just reply to this email.

\n

Best regards,
The Team

\n
" + } + }, + { + "id": "e6f7a8b9-c0d1-2345-efab-901234567890", + "name": "Sheets Audit Log", + "type": "n8n-nodes-base.set", + "typeVersion": 3.3, + "position": [600, 700], + "continueOnFail": true, + "parameters": { + "mode": "manual", + "duplicateItem": false, + "assignments": { + "assignments": [ + { + "id": "f7a8b9c0-d1e2-3456-fabc-012345678901", + "name": "timestamp", + "value": "={{ $json.grading.graded_at }}", + "type": "string" + }, + { + "id": "a8b9c0d1-e2f3-4567-abcd-123456789012", + "name": "email", + "value": "={{ $json.lead.email }}", + "type": "string" + }, + { + "id": "b9c0d1e2-f3a4-5678-bcde-234567890123", + "name": "name", + "value": "={{ ($json.lead.first_name || \"\") + \" \" + ($json.lead.last_name || \"\") }}", + "type": "string" + }, + { + "id": "c0d1e2f3-a4b5-6789-cdef-345678901234", + "name": "company", + "value": "={{ $json.enrichment.organisation.name || \"\" }}", + "type": "string" + }, + { + "id": "d1e2f3a4-b5c6-7890-defa-456789012345", + "name": "profile_grade", + "value": "={{ $json.grading.profile_grade }}", + "type": "string" + }, + { + "id": "e2f3a4b5-c6d7-8901-efab-567890123456", + "name": "source", + "value": "={{ $json.lead.source || \"\" }}", + "type": "string" + }, + { + "id": "f3a4b5c6-d7e8-9012-fabc-678901234567", + "name": "provider", + "value": "={{ $json.enrichment.provider }}", + "type": "string" + }, + { + "id": "a4b5c6d7-e8f9-0123-abcd-789012345678", + "name": "credits_consumed", + "value": "={{ $json.enrichment.credits_consumed }}", + "type": "number" + }, + { + "id": "b5c6d7e8-f9a0-1234-bcde-890123456789", + "name": "credits_low", + "value": "={{ $json.enrichment.credits_low }}", + "type": "boolean" + } + ] + }, + "options": { + "includeOtherFields": false + } + } + }, + { + "id": "c6d7e8f9-a0b1-2345-cdef-901234567890", + "name": "Error Trigger", + "type": "n8n-nodes-base.errorTrigger", + "typeVersion": 1, + "position": [0, 700], + "parameters": {} + }, + { + "id": "d7e8f9a0-b1c2-3456-defa-012345678901", + "name": "Error Notification Email", + "type": "n8n-nodes-base.emailSend", + "typeVersion": 2.1, + "position": [300, 700], + "credentials": { + "smtp": { + "id": "XU85XBahrbhS0122", + "name": "CORBEL Email SMTP" + } + }, + "parameters": { + "fromEmail": "jake@corbel.consulting", + "toEmail": "jake@corbel.consulting", + "subject": "Lead Actions workflow error", + "emailFormat": "html", + "html": "=

The Lead Actions Example workflow encountered an error.

{{ JSON.stringify($json, null, 2) }}
" + } + } + ], + "connections": { + "Execute Workflow Trigger": { + "main": [ + [ + { + "node": "Grade Router", + "type": "main", + "index": 0 + } + ] + ] + }, + "Grade Router": { + "main": [ + [ + { + "node": "HubSpot Upsert", + "type": "main", + "index": 0 + }, + { + "node": "Slack Notification", + "type": "main", + "index": 0 + }, + { + "node": "Welcome Email", + "type": "main", + "index": 0 + }, + { + "node": "Sheets Audit Log", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "HubSpot Upsert", + "type": "main", + "index": 0 + }, + { + "node": "Sheets Audit Log", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Sheets Audit Log", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "Sheets Audit Log", + "type": "main", + "index": 0 + } + ] + ] + }, + "Error Trigger": { + "main": [ + [ + { + "node": "Error Notification Email", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "settings": { + "executionOrder": "v1" + } +}