HubSpot bots allows its users to build chat bots to interact with their users. A part of bots is the option to write a code snippet to control the bot. During this workshop we are going to build some code snippets to make some sick bots.
-
Create an account by responding to the email invitation
-
Go to "Conversations -> Chatflows" in the top nav of the portal after signing in
-
Click "More -> Clone" on the Chatflow named "Blank Bot"
-
Enter a unique name for your Bot Chatflow
-
Find your new Chatflow in the table
-
Click "More -> Move to top Priority"
-
Click "Edit"
-
Configure targeting
- set the targeting url to something unique
-
Toggle the switch in the top right corner of the page
-
Preview bot in sandbox
- go to https://app.hubspot.com/conversations-visitor-sandbox/8398068?showConfig=true&portalId=8398068
- configure subroute to match your unique targeting url
you should see something like this:
All bots consist of three things:
- A welcome message
- A prompt to start the conversation
- Follow up actions
A welcome message is a way to tell your user the purpose of the bot. It will display in a pop up while the widget is closed so it should be something to encourage your visitors to interact with your bot.
Bots require a prompt to start the conversation so it knows a user has started an interaction. Otherwise it could send an unlimited number of messages without any user interaction. The follow up actions can collect information from quick replies or user input, send images or text, and branch to other parts of the boarder conversation tree. When an action is configured to take in user input, the bot will use natural language processing to try and pick out the relevant information from the user response. For example if I configure my bot to save information to the contact address field, it will specifically look for an address.
Connections are what tie together the bot actions into a conversation tree. Each action can be configured with a connection which will divert the bots conversation chain given certain parameters or responses. For example, if a visitor has already interacted with my bot or website and I've already collected their information I can divert my bot to skip the actions that collect that information. These connections can be found under the if/then branch tab of the bot action configuration panel.
Let's build a bot! There are a bunch of different things bots can do, but most make an api request and echo some data.
To help give some inspiration here is a list of public APIs https://github.com/toddmotto/public-apis
- Cat fact bot
- Stock Bot
- Trivia bot
- NOTE: This is an example from MotionAI's implementation (MotionAI is a software company that develops and "trains" chat bots that HubSpot acquired a year ago), so try to incorporate this example into your own
- Beer bot
- Created by Steve Rowell at HubSpot. This bot uses python which is not available to all at this time, but shows that you can collect information through quick replies in the lambda through creating a session and having states stored in a contact property. At HubSpot, we have beer on tap in a bunch of different locations, and using pubspot API, he created a way to output what's on tap. Super cool!
New to javascript? Here's a quick cheat sheet that goes over the syntax.
Can you make a bot with several code snippets and branching using nextModuleNickname
?
Behind the scenes our systems takes your javascript function and uploads it to AWS Lambada where it waits to be executed by the bot runner. AWS Lambda is a serverless on demand code execution environment that is really great at running a single snippet of code as it does not require having a system constantly running to execute code. Instead of having our own service and having to manage the very variable load of code snippet execution, we can call these lambdas on demand meaning we can execute as many as we want at any time. The downside is that there is a warm up period in order for the lambda executer to build the proper environment for us to execute the snippets in. To combat this, we use the same lambda environment across all of our usage at HubSpot which usually means the environment has been pre warmed up and is ready to execute.
- AWS Lambda: How it Works
- Benchling CRISPR Case Study
- Creating AWS Lambda Function Through AWS Console
🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖🤖