Automate HubSpot Chat with OpenAI Assistant in n8n

Struggling to manage customer queries in HubSpot chat efficiently? This unique n8n workflow integrates HubSpot Conversations with OpenAI Assistant to automate intelligent chat responses, saving time and enhancing customer experience.
httpRequest
switch
airtable
+4
Workflow Identifier: 1072
NODES in Use: HTTP Request, Switch, AirTable, Code, Wait, Webhook, OpenAI
Automate chat with n8n and OpenAI

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow connects HubSpot Conversations with an OpenAI Assistant to answer chat messages automatically. It helps fix slow replies, repeated questions, and mistakes that annoy customers. The workflow reads new HubSpot messages, talks to OpenAI to get replies, and sends those back to HubSpot fast.

The system looks if there is already an AI conversation linked to the chat using Airtable. If not, it starts a new AI thread. It keeps track so the chat history is saved. It also waits for the AI to finish before replying. This way, the support team saves time and customers get quick answers.


Tools and Services Used

  • HubSpot Conversations API: Sends new chat messages to the workflow.
  • OpenAI API: Runs the AI assistant to create answers.
  • Airtable: Stores the link between HubSpot threads and OpenAI threads.
  • n8n Automation Platform: Runs all nodes and logic to connect everything.

Inputs, Processing, and Outputs

Inputs

The trigger is a new HubSpot chat message, sent to a Webhook node. It must have a message ID to continue. The workflow fetches full message details from HubSpot.

Processing Steps

  • Check if the message sender is the bot itself; if yes, stop to avoid reply loops.
  • Search Airtable for a matching conversation thread with the current HubSpot thread ID.
  • If no matching thread is found, create a new OpenAI assistant thread and save the mapping in Airtable.
  • Run OpenAI assistant either on the new or existing thread, sending the user message.
  • Poll the assistant run status with wait cycles until it is complete.
  • Handle any required external functions by calling APIs and submitting results back.
  • Once done, get the AI response message.
  • Send the AI reply back to HubSpot Conversations as a chat message.

Output

The final output is an AI-generated message posted automatically into the HubSpot chat thread. This allows quick, human-like replies without agent delays.


Beginner Step-by-Step: How to Use This Workflow in n8n

Importing the Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open the n8n editor where you want to use the workflow.
  3. Use the “Import from File” option to load the downloaded workflow.

Configuring Credentials and IDs

  1. Add your HubSpot App Token credential inside n8n.
  2. Add your OpenAI API Key credential.
  3. Provide your Airtable API Key and configure the base and table names.
  4. Update any hardcoded IDs such as bot actor ID, workspace IDs, channel IDs, or table fields if needed.

Testing and Activating

  1. Trigger the Webhook node manually or with a test HubSpot message.
  2. Watch each node execute correctly in the n8n execution log.
  3. If all nodes succeed, toggle the workflow to “Active” for production use.
  4. Make sure the webhook URL is publicly accessible and configured in HubSpot webhook subscriptions.
  5. Check logs regularly to monitor performance and failures.

For users running self-host n8n, ensure the server is reachable from HubSpot for webhook calls.


Customization Ideas

  • Change the IF node filter for your bot’s specific actor ID to stop reply loops.
  • Add new API calls by extending the Select Function switch node with new HTTP Request nodes.
  • Adjust Wait nodes times to match expected OpenAI response delays.
  • Modify the message format in respondHubspotMessage1 for richer text or markdown.
  • Expand the Airtable schema to keep more context about customer chats.

Troubleshooting Common Issues

  • 401 Unauthorized from HubSpot API
    Cause: Invalid HubSpot App Token
    Solution: Refresh or re-authenticate the App Token credential in n8n.
  • OpenAI assistant never completes
    Cause: Wrong thread ID or missing assistant ID
    Solution: Check Airtable stored thread IDs and assistant IDs match those in OpenAI requests.
  • Infinite chat reply loops
    Cause: Not filtering out bot’s own messages by actor ID
    Solution: Update the IF node condition to block processing messages sent by the bot.
  • JSON parse errors submitting function outputs
    Cause: Improper escape of JSON strings
    Solution: Use the provided JavaScript code in the Code nodes to escape JSON before submitting back.

Pre-Production Checklist

  • Check webhook URL configuration in HubSpot webhook subscriptions.
  • Manually test HubSpot message retrieval with the HTTP Request node.
  • Verify Airtable credentials, base, and table schema.
  • Test OpenAI assistant thread creation and run calls.
  • Confirm capable posting back to HubSpot Conversations with correct IDs.
  • Enable error handling and system logging inside n8n.
  • Backup Airtable data before going live.

Summary

✓ The workflow automatically replies to HubSpot chat messages using OpenAI.

✓ It keeps conversation history with Airtable linking HubSpot and OpenAI threads.

✓ The user saves time by reducing manual responses and avoids repeated questions.

→ Users get fast, AI-driven support replies that improve customer experience.

→ The system detects bot messages to prevent reply loops.

→ The workflow handles multi-step conversations by polling OpenAI runs and invoking functions.


Automate chat with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

Author
Written By
Vikash Kumar
Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.
Author
Written By
Vikash Kumar
Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.

Frequently Asked Questions

The workflow requires HubSpot App Token, OpenAI API Key, and Airtable API Key credentials configured inside n8n.
It uses an IF node that filters out messages sent by the bot actor ID to stop infinite reply loops.
Yes, it polls OpenAI runs for completion and submits function API results to enable multi-step chats.
Download the workflow file, import it in n8n, add required credentials, update IDs if needed, test the workflow, then activate it for production.

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.