- Overview and Key Notes
- Initial Setup Steps
- Setting Up the Chatbot Flow
- New Chat Prospect Trigger Node
Overview and Key Notes
This guide explains how to configure your HubSpot chat to send prospects a booking link within a chat message. If you have any questions during setup, please contact LeanData Support.
Initial Setup Steps
Adding the BookIt Log ID Field
To connect LeanData’s routing and scheduling with the leads or contacts created through your chatbot, you’ll need to add a property to store the BookIt Log ID. This Log ID should be passed to Salesforce and stored on the corresponding lead or contact record through HubSpot.
-
In HubSpot, create a new property on the Contact object.
-
- You can name this property anything, but we recommend ld_bookit_log_id.
- Make note of the name you choose—you’ll need it in a later step.
- Set the field type to Single-line text.
-
Once the property is created, configure it 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, create a workflow to assign a unique value to the Log ID property on the associated contact for each new conversation generated by the chatbot.
To do this, navigate to the Workflows tab and create a new workflow.
Select a Conversation-based workflow and ensure that the Blank workflow option is selected
Start by adding an enrollment trigger that runs when a conversation object is created.
Now that the workflow has been created, add a Set property value step
Use this workflow to set the LD BookIt Log ID property (created earlier) on the associated contact for each new conversation.
The value to set should be a combination of: <LeanData Org ID>_<Thread ID>
To find your LeanData Org ID, go to the BookIt Settings page in LeanData and copy the value labeled BookIt Org ID
In the Set property value step, paste your LeanData Org ID into the value field, followed by an underscore (_).
Next, use the Insert data menu to add the Thread ID variable. When finished, the value field should display in the format shown in the screenshot below.
Click Save on this workflow step, then insert a Delay step between the Contact enrollment trigger and the Set property value steps.
Set the delay to a Fixed amount of time of 1 minute. This delay ensures the conversation has enough time to properly associate with the 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 it’s time to incorporate BookIt into your chatbot flow.
At the point where you want the calendar to appear, add a Send simple message block to let the user know that the next message will contain their booking link.
Next, add a Run a code snippet block to generate the calendar link that will be shared with the user.
Set the Runtime to Node 18.x, then paste in the following code.
You will need to update the placeholder values (highlighted in yellow).
Replace the placeholders with your values:
-
<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”.
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 booking link and proceed to the default next module. const responseJson = { botMessage, responseExpected: false }; callback(responseJson); };
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, configure mappings between your form fields and the variables they correspond to in your FlowBuilder graph. The Form Field API Names represent the property API names you are collecting in your chatbot and want to send for routing. For HubSpot Company properties (e.g., companysize), prefix the name with 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.