top of page
Search

Beyond Chat: How to Build a Chatbot That Takes Action


Chatbots have come a long way—from simple FAQ responders to intelligent assistants capable of executing tasks. But what if your chatbot could go beyond answering questions and actually take action? In this guide, we’ll enhance a chatbot into an Agentic Chatbot, enabling it to create customer support tickets in a CRM system automatically.



What is an Agentic Chatbot?


A traditional chatbot responds to queries using predefined scripts or AI-based responses. An Agentic Chatbot, on the other hand, goes beyond passive interaction—it takes action based on user requests by integrating with external systems such as CRMs, databases, or other enterprise applications.


Scenario: Automating Support Ticket Creation


In this example, we will implement an AI-powered chatbot that can:

1. Understand a customer’s support request.

2. Collect necessary details such as issue type and description.

3. Automatically create a support ticket in HubSpot CRM.



Technology Stack


We will use the following tools to build our Agentic Chatbot:

OpenAI API – Provides a Large Language Model (LLM) for natural language understanding and tool execution.

Flowise – A no-code platform that simplifies chatbot development and workflow orchestration.

HubSpot CRM – Our CRM of choice, where the chatbot will create support tickets using the HubSpot API.




Pre-requisites


Create a Private App in HubSpot to enable API access


To enable API access for creating tickets, follow these steps:

• Log in to HubSpot Developer Portal.

• Navigate to Apps → Private Apps.

• Create a new Private App with the “Tickets” scope enabled.

• Generate an API Token for secure access.


Refer to the official HubSpot guide for detailed steps:


Store the API Token in Flowise


Once you have the API token:

• Go to Flowise → Variables.

• Create a Static Variable to store the HubSpot API token securely.


Save API Token as Flowise Variable
Save API Token as Flowise Variable

Step-by-Step Implementation


Step 1: Create a New Chatflow


Open Flowise and navigate to Chatflows.

Click Add New and name your chatbot.

Save the flow.


Create a new chat flow
Create a new Chat Flow

Step 2: Add Core AI Components


Click Add Node → Tool Agent 

The Tool Agent is responsible for orchestrating Tool usage.


Tool Agent
Tool Agent Node

Add a ChatOpenAI node:


ChatOpenAI Node
ChatOpenAI Node for the Chat Model

Select your OpenAI credential.

Select a model such as GPT-4o-mini or a similar latest version.

Connect it to the Tool Agent node as above.


Add a Buffer Memory node and link it to the Tool Agent node to maintain conversation context.


Buffer memory node
Buffer Memory to store Chat context

Step 3: Implement the Ticket Creation Tool


Add a new Custom Tool node.

From the Select Tool dropdown, click Create New.


Create custom tool
Create Custom Tool

Define:

Tool Name: “Create HubSpot Ticket”

Tool Description: Clearly explain the tool’s purpose (LLM will use this for tool selection).


In the Input Schema, define the required parameters:


Ticket Subject (Text)

Ticket Content (Text)

Define custom tool
Define Custom Tool

Implement the tool using JavaScript:

The custom tool is created with a sample JavaScript function template. This needs to be edited to suit our needs.


Sample JavaScript
Sample JavaScript Template

Modify the API endpoint to use HubSpot’s tickets API.

• Retrieve the stored API token from Flowise variables.

• Pass the collected ticket details to the API.


const fetch = require ('node-fetch');
const url = 'https://api.hubapi.com/crm/v3/objects/tickets';
const token = $vars.hstoken;
const options = {
	method: 'POST', 
	headers:{
		'Content-Type': 'application/json',
		'Authorization': 'Bearer ${token}'
	},
body: JSON.stringify({
	properties: {
		hs_pipeline: "0", 
		hs_pipeline_stage: "1", 
		hs_ticket_priority: "HIGH", 
		content: $content, 
		subject: $subject
	}
})
};
fetch(url, options)
	.then (response => response. json ())
	.then (data => console. log ('Response:', data))
	.catch(error => console.error('Error:', error)) ;
return "Ticket created successfully;

Save and connect this tool to the Tool Agent node.

The final Flowise chat flow should look like the below.


Final chat flow
Final Flowise Chat Flow

Step 4: Testing the Agent


Now that the chatbot is configured, let’s test its functionality:


Start a conversation by clicking on the Chat icon on the top right of the chat flow

The chatbot should ask for ticket details (subject and description).

Once the chatbot receives the required input, it will automatically call the HubSpot API and create the ticket.

Test the bot
Testing the Agent Bot

Check HubSpot CRM

Log in to HubSpot and verify that the ticket appears with the details entered during the chat.


HubSpot ticket
Ticket in HubSpot

Next Steps: Enhancing the Chatbot


This chatbot can be further improved by:


  • Collecting customer identification details and linking the ticket to an existing contact.

  • Enabling multi-step interactions where the bot suggests solutions before creating a ticket.

  • Extending integrations to Slack, Teams, or email notifications.


Once satisfied, embed the chatbot on your website:


  • Click the Code Embed button in Flowise.

  • Copy the provided HTML snippet.

  • Paste it into your website’s CMS or editor.


By leveraging Flowise, OpenAI, and HubSpot, we’ve transformed a simple chatbot into an agentic chatbot capable of automating customer support workflows. This approach not only improves efficiency but also enhances the customer experience by reducing response times.


Are you ready to build an intelligent agent for your business? Start implementing today and bring automation to the next level! If you need any assistance, just give us a call!







 
 
 

Commenti


contact@techfuse.ai

18 King Street East, Suite 1400, Toronto, ON, Canada, M5C 1C4

Stay in Contact with us

Submission Successful!

Connect with Us:

  • LinkedIn
  • Facebook

© 2024 TechFuse All Rights Reserved

bottom of page