BookIt for Forms - Chatbot Integration with Hubspot - Smart Booking Link Follow
- Overview
- Initial Setup Steps
- Adding the BookIt Log ID Field
- Creating a Workflow to Update the Log ID
- Setting Up the Chatbot Flow
- Adding the Calendar Steps
- New Chat Prospect Trigger Node
Overview
The following guide will walk through the process of setting up your Hubspot chat conversation to provide a prospect with a link to make a booking in a chat message. If any questions arise, please reach out to LeanData support.
Initial Setup Steps
Adding the BookIt Log ID Field
To link our routing and scheduling process to the leads/contacts created through your form, you’ll need to add a hidden field to your form following the steps below. This field will store our log id that should eventually be placed on your lead or contact record in Salesforce through your marketing automation.
To do this, first create a field on your contact object in Hubspot. This field can be called anything, but we recommend calling it “ld_bookit_log_id”. Just be sure to make note of what you name this field as you will be needing this in a later step.
This field should have a “Single-line text” field type as shown below.
Important: Now that the property has been created, you’ll need to set up this property to map to a field on your lead/contact object in Salesforce via a two-way sync.
Creating a Workflow to Update the Log ID
Next, we will need to create a workflow that assigns a unique value to this newly created log id field on the associated contact for each conversation that gets created from the chatbot
Begin by creating a new workflow under the “Workflows” tab
Select a “Conversation-based” workflow and ensure that the “Blank workflow” option is selected
To begin, we will add an enrollment trigger to this workflow to trigger when a conversation object is created. Note: if we are only implementing BookIt on a subset of your chatbots, feel free to add additional conditions on this enrollment trigger to ensure that only chatbots with BookIt enter this workflow.
Now that the workflow has been created, add a “Set property value” step
We will set the “LD BookIt Log ID” property created earlier on the associated contact for each conversation using this workflow.
The value being set will be the following combination: <LeanData Org ID>_<Thread id>
To get your <LeanData Org ID>, navigate to the BookIt for Forms settings page in LeanData and copy your “Org ID for Chatbot Compatibility”
Go ahead and paste this value in the value field of the “Set property value” step and follow it up with an underscore
Follow this value up by selecting the “Thread id” variable from the “Insert data” menu and verify the value input box has a value with the same format as shown in the screenshot below
Click “Save” on this workflow step and add a new “Delay” step between the “Contact enrollment trigger” and the “Set property value” steps
Configure this delay to be based on a “Set amount of time” of 1 minute. This delay is required to allow time for the conversation to be associated to a contact
Save this step and click “Review and Publish”
Review the settings and turn on the workflow once finished
Setting Up the Chatbot Flow
Adding the Calendar Steps
Now, we will begin incorporating BookIt into your chatbot flow
At the point you would like the calendar to appear in your chatbot flow, first add a “Send simple message” block to inform the user that the next message shown will be a booking link
Next we will add in some code to generate the calendar link we will prompt the user to schedule at. To do this, add a “Run a code snippet” block, select “Node 18.x” as the “Runtime”, and paste in the following code:
exports.main = (event, callback) => {
let orgId = '<LeanData Org ID>';
let nodeName = '<Trigger Node Name>';
let contactProperties = event.session.properties.CONTACT;
let companyProperties = event.session.properties.COMPANY;
let paramsArray = [];
for (let key of Object.keys(contactProperties)) {
paramsArray.push(key + '=' + contactProperties[key].value);
}
for (let key of Object.keys(companyProperties)) {
paramsArray.push('0-2/' + key + '=' + companyProperties[key].value);
}
let encodedParamsString = paramsArray.join('&') + `&uid=${`${orgId}_${event.session.properties.CONVERSATION.threadId.value}`}`
const beginningString = `id=${orgId}&nodeName=${encodeURIComponent(nodeName)}&isUsingHerokuId=true&`;
const btoa = str => {
return Buffer.from(str).toString('base64');
};
let botMessage = `https://app.leandata.com/r/${btoa(beginningString + encodedParamsString)}`;
// Your Bot will return the message "Hello World" and proceed to the default next module.
const responseJson = {
botMessage,
responseExpected: false
}
callback(responseJson);
};
You’ll need to configure this snippet by changing the parts of this code to the following (remember to remove the ‘<>’ brackets):
- <LeanData Org ID> - The same org ID copied from your BookIt settings in LeanData from an earlier step
- <Trigger Node Name> - The name of the trigger node on your live BookIt router graph that you would like to enter the graph through. There will be instructions for the configuration of this in a later step, so for now, just enter a generic name like “New Chat Prospect”.
New Chat Prospect Trigger Node
Finally, you will need to set up a New Chat Prospect Trigger Node to map the fields collected from your chatbot to your BookIt Flowbuilder graph.
From the Node Bar, drag in a New Chat Prospect Trigger Node and open it.
In the Form Field Mapping section, set up the mappings between your Form Fields to the variables they will correspond to in your FlowBuilder graph. Here, the “Form Field API Names” are the API Names of the properties you are collecting in your chatbot and would like to send over for routing. For any company properties (e.g. companysize), you will need to prefix this with a 0-2/ (e.g. 0-2/companysize).
Please reach out to support if you need assistance with this.
After creating your mappings, in the Trigger Edge section, direct the Insert edge of New Chat Prospect Trigger Node to the next step in your graph or you can do so visually from within the FlowBuilder interface.