Animated data flow diagram

AI-Powered HubSpot Chat Assistant using OpenAI & n8n

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

OpenAI HubSpot Airtable

Overview

Unlock Intelligent Customer Conversations with this AI Agent

This n8n workflow transforms your HubSpot chat into an intelligent, 24/7 support channel powered by OpenAI Assistants. It acts as an AI Agent that automatically fetches new chat messages from HubSpot, understands the user's intent using advanced AI, and crafts relevant responses. The agent can maintain conversation history by mapping HubSpot threads to OpenAI threads using Airtable, ensuring contextual follow-ups. Furthermore, it's equipped with function-calling capabilities, allowing it to interact with external APIs (like the demonstrated listafirme.ro for company data retrieval) to gather information and provide more comprehensive answers directly within the chat.

Key Features & Benefits

  • Seamless HubSpot Integration: Directly connects to your HubSpot chat to manage incoming messages and send AI-generated replies.
  • Advanced Conversational AI: Leverages the OpenAI Assistants API for sophisticated natural language understanding, context management, and response generation.
  • Persistent Conversations: Utilizes Airtable to store and retrieve mappings between HubSpot and OpenAI conversation threads, enabling continuous and contextual interactions.
  • AI Function Calling: Supports OpenAI function calling to connect with external APIs and services, enriching the assistant's knowledge and capabilities (e.g., live data lookups for company information).
  • Automated Customer Support: Handles common queries and tasks automatically, significantly reducing agent workload and improving response times.
  • Enhanced Efficiency: Frees up your human support team to focus on more complex customer issues that require direct intervention.
  • Always-On Availability: Provides instant support to customers around the clock, improving user satisfaction and engagement.

Use Cases

  • For B2C e-commerce: Instantly answer customer questions about orders, shipping status, product details, or return policies via HubSpot chat.
  • For B2B SaaS: Qualify leads interacting through your website chat by asking pre-defined questions, gathering initial information, and scheduling demos if criteria are met.
  • Automate responses to frequently asked questions (FAQs) across various topics, reducing the need for human intervention for Level 1 support.
  • Dynamically fetch and provide specific data during a chat, such as looking up company details for B2B sales inquiries or checking product availability for e-commerce customers.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • OpenAI API Key with access to the Assistants API (e.g., gpt-4 or gpt-3.5-turbo models configured for your assistant).
  • An OpenAI Assistant ID, pre-configured with appropriate instructions and any necessary function definitions.
  • HubSpot account with an App Token for API access.
  • Airtable account, API key, Base ID, and Table ID. Your Airtable table should be set up with columns like 'Hubspot Thread ID' and 'OpenAI Thread ID' to map conversations.
  • (Optional) API credentials for any external services you plan to integrate via OpenAI functions (e.g., an API key for a service like listafirme.ro if you implement that specific function).

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Configure the 'Webhook' node: by default, it's set to path hubspot-tinder. You may need to adjust this or integrate it with your specific HubSpot chat new message trigger mechanism.
  4. Update HubSpot Nodes: Configure 'getHubspotMessage' and 'respondHubspotMessage1' nodes with your HubSpot App Token credentials. Ensure the senderActorId in 'respondHubspotMessage1' matches your bot's actor ID (the IF node uses this to prevent self-replies).
  5. Configure Airtable Nodes: In 'Airtable' (search operation) and 'createThread' (create operation) nodes, enter your Airtable API Key, the correct Base ID, and Table ID. Verify field names match your Airtable setup (e.g., 'Hubspot Thread ID', 'OpenAI Thread ID').
  6. Configure OpenAI Nodes:
    • For all HTTP Request nodes making calls to OpenAI ('OpenAi Create Thread', 'OpenAI Run', 'Get Run', 'Get Last Message', 'Submit Data', 'Submit Data1') and the '@n8n/n8n-nodes-langchain.openAi' node ('OpenAI'): Enter your OpenAI API Key in the credentials section.
    • Update the assistant_id in the 'OpenAI Run', 'OpenAI Run1', and the 'OpenAI' (Langchain node) parameters to your specific OpenAI Assistant ID. This assistant must be pre-configured on the OpenAI platform.
  7. Configure OpenAI Assistant and Function Calls (if used):
    • On the OpenAI platform, define any functions your assistant needs to call (e.g., for looking up external data). Specify the function name and expected arguments.
    • In the n8n 'Select Function' node, ensure the conditions (e.g., getAWBbyOrder, get_awb_history are examples) exactly match the name of the functions your OpenAI Assistant is configured to call.
    • Verify that the subsequent HTTP Request nodes (e.g., 'HTTP Request' and 'HTTP Request1' for listafirme.ro examples) correctly parse arguments from the assistant's function call (tool_calls[0].function.arguments) and use them as needed.
  8. Review and Adjust Wait Nodes: Modify the duration in 'Wait', 'Wait1', 'Wait2', 'Wait3' nodes if necessary, to allow sufficient time for OpenAI Assistant processing.
  9. Test Thoroughly: Send test messages through your HubSpot chat to ensure the flow works end-to-end, including thread creation/retrieval, AI responses, and any function calls.
  10. Activate the workflow.

Tags:

AI AgentHubSpotOpenAICustomer SupportChatbotAutomationAirtableAPI IntegrationConversational AI

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation