Simple flow
Alright, let’s put the fundamentals of chat flow into practice and develop a basic chat flow.
Here is the flow we will implement in this tutorial:
- The chatbot sends a greeting message.
- It then prompts the customer to provide their email and name.
- The email input is validated using the “Email” validator.
- If the email is invalid, the bot notifies the customer.
- Once all the data is collected, the bot sends a message with some buttons and emails the customer data to the admin.
- The first button will send an invitation to the agent.
- The second button will serve as a link to the website.
- If the agent does not connect within 20 seconds, the bot will send a fallback message to the customer.
Preparing variables
Before we begin building our chat flow, let’s prepare a couple of variables. We need:
- {name} to store the customer’s name
- {email} to store the customer’s email
Start the bot and send a greeting message
To initiate the bot without customer interaction, we will use the “Before new thread start” event trigger. This way, when a customer visits our website, the chatbot will automatically be activated.
Next, we need to link a “Message” action for the greeting to the event trigger.
Collect the customer’s name and email
Next, we will prompt the customer to enter their name. Anticipating a response, we need to enable the “Wait for reply” option for this action. To store the customer’s name and include it in the email, we should also enable the “Save to variable” option and select the {name} variable we previously created.
After obtaining the customer’s name, let’s request their email address. You can duplicate the previous action, enable the “Wait for reply” option, and save the response to the {email} variable. Additionally, we need to apply the “Email” validation to ensure the input is a valid email address.
Let’s also draft a message to send to the customer when the provided input is not a valid email address.
Next, let’s link all the created actions together.
Send a success message to the customer and an email to the admin
Great, we now have all the required data to move forward. Let’s send a “success” message to the customer. Additionally, we’ll notify the admin via email that the customer has completed the data submission. Lastly, we need to store this data in the contact information database.
Additionally, our new action should include two buttons:
- The first button will invite the agent to join the chat.
- The second button will be a link to our website.
Invite the agent to the conversation
Now let’s incorporate the “Invite agent” action. Additionally, we need to set a timeout of 20 seconds. If no agent connects within this timeframe, the customer should receive a notification indicating that no agents are available at the moment.
Conclusion
We have successfully created a useful chat flow that can help us collect customer data for further processing.
The complete diagram of the chat flow is provided below.
ChatGPT
Let’s develop a chat flow that integrates ChatGPT. This will enable our chatbot to address fundamental inquiries about the company and its products, such as the company’s location, primary business, main functionalities of the product, pricing, and more.
First, we need to establish a starting point for our chat flow. Let’s use the /start bot command for this purpose.
Next, we will include a greeting message and wait for the customer’s response.
Next, let’s integrate ChatGPT by selecting the GPT-4o model from OpenAI. Additionally, we need to include some text instructions detailing information about the company and the product we are selling.
Additionally, we will incorporate a custom function. If the customer wishes to contact the sales team, the subsequent sub-tree will be activated.
That’s it! We have successfully integrated ChatGPT into our chat flow. Furthermore, you can leverage the ChatGPT assistant functionality to train the chatbot using your own data files.