Category: Automations › Lead Generation & CRM · Best for: HubSpot users wanting a website AI chat · Platform: n8n · Steps: 26
What it does
An AI answers visitors on your site and saves the chat in HubSpot.
This can be triggered with n8n chat widget, hubspot or other chat services.
Works with: Airtable, OpenAI
What you get
- The n8n workflow file (
workflow.json), ready to import - This setup guide
- The list of fields to change for your own accounts (see Install below)
- Email support if you get stuck
Before you start
-
An n8n account. Easiest: n8n Cloud (free trial). Self-host for free with Docker:
docker run -it --rm -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n, then open http://localhost:5678. -
Accounts and API keys for these services:
- HubSpot app / private app token: how to connect (used by getHubspotMessage, respondHubspotMessage1)
- OpenAI API key: how to connect (used by OpenAi Create Thread, OpenAI Run, Get Run, Get Last Message, Submit Data, Submit Data1, OpenAI Run1, OpenAI)
- Airtable personal access token: how to connect (used by Airtable, createThread)
Install
- In n8n, click Create workflow (top right).
- Click the ⋯ menu → Import from file and choose
workflow.json. Or open the file, copy everything and paste it onto the empty canvas with Ctrl/Cmd + V. - Open each node with a red warning triangle and pick or create the matching credential from the list above.
- Point these fields at your own sheets, chats and accounts:
- Airtable →
base: choose your own - Airtable →
table: choose your own - createThread →
base: choose your own - createThread →
table: choose your own
- Airtable →
- Click Save.
Test it
- Click Test workflow (or Execute workflow). Webhook starts it. Trigger it once with real sample data.
- Click each node to check its output. A green tick means the step worked.
- Fix any red node: it's almost always a credential or a field that still points at a sheet or chat that isn't yours.
Go live
Toggle Active (top right). From now on it runs on its own. Check Executions in the left sidebar to see every run.
How it works, step by step
- Webhook starts the workflow (Webhook).
- IF2 checks a condition and routes items accordingly.
- getHubspotMessage calls an external API (=https://api.hubapi.com/conversations/v3/conversations/threa).
- IF checks a condition and routes items accordingly.
- Airtable uses Airtable to search.
- IF1 checks a condition and routes items accordingly.
- OpenAi Create Thread calls an external API (https://api.openai.com/v1/threads).
- OpenAI uses AI (OpenAI).
- createThread uses Airtable to create.
- OpenAI Run1 calls an external API (=https://api.openai.com/v1/threads/{{ $('Airtable').item.jso).
- OpenAI Run calls an external API (=https://api.openai.com/v1/threads/{{ $json["OpenAI Thread I).
- Get Run calls an external API (=https://api.openai.com/v1/threads/{{ $json["thread_id"] }}/).
- Completed, Action or Inprogress checks a condition and routes items accordingly.
- Get Last Message calls an external API (=https://api.openai.com/v1/threads/{{ $json["thread_id"] }}/).
- Select Function checks a condition and routes items accordingly.
- Wait1 pauses before continuing.
- Wait pauses before continuing.
- respondHubspotMessage1 calls an external API (=https://api.hubapi.com/conversations/v3/conversations/threa).
- HTTP Request calls an external API (=https://www.listafirme.ro/api/search-v1.asp).
- HTTP Request1 calls an external API (=https://www.listafirme.ro/api/info-v1.asp).
- Code1 reshapes the data for the next step.
- Code reshapes the data for the next step.
- Submit Data calls an external API (=https://api.openai.com/v1/threads/{{ $('Select Function').i).
- Submit Data1 calls an external API (=https://api.openai.com/v1/threads/{{ $('Select Function').i).
- Wait2 pauses before continuing.
- Wait3 pauses before continuing.
India & US notes
India: Zoho CRM and WhatsApp follow-ups are the most common combo; you can swap the CRM node for Zoho CRM. US: HubSpot free CRM is the usual starting point.
Extra setup notes
These notes are also on the canvas as yellow sticky notes:
Watch for new message on the chatbot. This can be triggered with n8n chat widget, hubspot or other chat services.
Post assistant Message back to chat service, in this case Hubspot
Create a new Thread, save it to database and RUN
UPDATE USER FILTER FOR DUPLICATION
Search for Thread ID in a database.
This database is maintaing references between messaging service thread id and OpenI Thread ID.
POST a new message to existing thread.
Get Run Status: If still in progress, run again. If action needed go to respective action. If Completed, post message.
Run required actions based on Assistant answer and respond to Assistant with the function answer.
Each route is a function that you need to define inside your assistant configuration.
Troubleshooting
- "Credentials not found": open the node and select your credential again.
- Google "access blocked": in Google Cloud, add your email as a test user on the OAuth consent screen.
- Webhook not firing: copy the node's Production URL (not Test URL) into the other app, and make sure the workflow is Active.
- AI node errors: check your API key has billing enabled and the model name exists on your plan.
- Nothing happens on schedule: the workflow must be Active, and self-hosted n8n must stay running.
Need help?
Reply to your Morning Method order email and we'll help you get it running.
© Morning Method