This article will help you to create a simple pre-conversation survey bot. This bot will use a predefined template to get the visitor's name, email address, and phone number.
If you are new to our modern Messaging platform, this bot replaces the older pre-chat survey method used in our legacy Live Chat platform.
Tip: To get expert help in building and implementing your bot, reach out to your Account Director to discuss our Professional Services offering.
Table of Contents
- Step 1: Create a Bot using the Predefined Template
- Step 2: Customize the Interaction
- Step 3: Create a Matching Engagement
- Next Step: Deploy the Bot
- See Also
Step 1: Create a Bot with the Attached Predefined Template File
To begin, you need to create a bot in the Conversation Builder using a predefined template file. We've attached the template file to this article, to help you with this step.
- Download the bot JSON file attached to this article. Either scroll down to the bottom of the page to find it or use this direct link to the download.
- Login to the Engagement Portal. (How to login to the Engagement Portal)
- Open the menu on the left side of the page and select Automate > Conversation Builder.
- Click in the upper-right corner.
- In the dialog box that opens, navigate to and select the JSON file that you downloaded earlier. Then click Open. The bot will be imported and given a name that includes a date and timestamp. You can change the bot name later if you prefer.
- The Conversation Builder dialog editor will open. A bot with a “Welcome” dialog that matches and responds to “hi” will be created. The bot has predefined survey questions, an agent escalation dialog, and a fallback dialog.
It also has a private message dialog in JSON format which holds pre-conversation data to populate chat activity in Dynamics. It will capture the visitor's first name, last name, email address, and phone number.
Important: The bot created here will only work with our modern Messaging platform. It will not work with our legacy Live Chat platform.
Step 2: Customize the Interaction
Now you need to customize the bot for use with your organization. Build it out by completing and adding the following.
Add Dialogs and Interactions
The template starts you with a Dialog Starter which shows the following.
Note: Without a dialog starter the bot will fail to run.
In an engagement, the user starts the conversation with some input: a message or a question. In response, the bot tries to match the user input with a pattern or intent in the Dialog Starter. If a match is found, then that dialog is triggered, and its flow begins.
Adjust the dialog starter to include other patterns or intents, according to your needs.
Let's consider an example of a change to the dialog starter. Notice the action in the gif below. In it, we change the pattern from "hi" to "Start Chat." In our example, Start Chat is a predefined action for visitors that allows them to start a conversation, rather than allowing free text user input.
Since this is a pre-conversation survey, it is likely that you want all of your visitors to take it. This will shape which pattern or intent you pick; likely you want something that will trigger for all or almost all visitors.
Tip: See the Dialog Starter article in the LivePerson developer center to learn more. LivePerson is our partner and powers the underlying technology for our Messaging platform. They also have more information about patterns and how to specify them properly.
Now we need the bot to start asking questions. You can see the Interaction Selector on the right-hand side of the page. Under the Questions sections, there is the option to select Text Question.
The bot has a predefined question asking for the customer's name, with entry validation. You can start with this and add the questions you wish to have for your pre-conversation survey.
In the example shown under the next subheading (custom rules), we're going to request the customer's name, phone number, and email address. This means adding two more text questions:
- What is your email?
- What is your phone number?
Tip: You can also name the questions so they are easier to identify. This becomes useful if you're creating large interactive bots.
Add Custom Rules for Validation
Now, how do we try to stop consumers from entering the wrong information? We need to add Custom Rules.
- Click the drop-down box for the next action and select .
- Specify the Rule name and click .
- A number of regexes will be provided for you by pressing Hint. You will need to select the 'Phone Number' regex for the Phone number and 'Email' regex for the Email.
- Copy the regex using the Copy button next to it and paste this where it states 'Enter regex'.
Then, click . - Now if a user tries to enter the wrong information, the fallback message will be provided.
However, we want something more specific for each question so we're going to add another Custom Rule. - Again, set this to First Name but it will need to be repeated for all questions.
- This time we need to set it to 'No Match' so if it doesn't match the regular expression then we can choose what message is returned and which action the bot will respond with.
- As you can see, it looks to see if it matches. If it doesn't, it sends the message “Please enter a valid first name.” and then returns the customer to the 'Request First Name' question.
Note: You will need to repeat this process for each question.
User responses to question interactions can be saved in Variables, making them available for future use.
Store User Responses in Variables
Here is an example of how you can store the user's name and repeat it back to them.
- In this example, we will use the variable {$query} to store the response and give it the Variable Name: 'firstName'
- To reference the variable, we use:
{$botContext.firstName}
We can then use this in a text or any other interaction.
Note: Obtain variables using API.
Transfer the Conversation to an Agent
You will need to set up the bot to route the conversation to an agent after the survey is finished. You can do this by choosing a Skill for it to be transferred to.
To specify the skill, you first need to get the Skill ID from the skills list.
- Open the menu on the left side of the page and select Manage > Users & Skills.
- Select Skills. You may need to create a new skill and assign it to a user. (Think about what will work best for your organization.)
- Open the Skill you want the bot to route the conversation to after taking the survey. This opens the skill page.
- Example the Skill page URL to find the Skill ID. In the example below, the Skill ID is 2103520550.
-
Go back to the Conversation Builder and then to the bot you just created. From the menu on the left side of the page select Automate > Conversation Builder > (Bot name).
- Click the agent transfer dialog. It will show that the 'Agent skill id is not set.'
This is where you will use the number obtained from the Skill ID earlier. -
Go to Settings. Select Advanced and enter the Skill ID obtained earlier. Then click .
Step 3: Create a Matching Engagement
In order for the bot to be reached, you need to assign the bot to a skill. You then need an engagement that assigns the conversation to that skill.
Note: Assigning the bot to a skill is different from what you just did in the previous step, which is choosing the Skill for agent transfer. In that step, you chose the Skill to which the bot will send the conversation after it is done. Now we are referring to choosing the Skill that the bot itself will be part of.
You can typically assign the bot to a Skill as part of the deployment process. When you finish all of the steps in this article, you will get to the "next step" heading. It will send you to an article that will help you deploy your bot. One of the steps in that article will have you add the Skill to your bot, so you can wait to handle it until then. We just want you to be aware that it is necessary.
Let's consider the process of setting up an engagement that uses that bot. You can either create a new engagement or adjust the settings on an existing engagement.
- Go to Engage > Campaign Builder from the left navigation menu.
- You can add your bot configuration to any Engagement or Campaign. For this example, however, let's create a new campaign and engagement. Click
- Fill in the following values and select Add Engagement > Web.
-
Select the options you wish to use.
- On the Engagement settings page, ensure the following values are set:
- Conversation Type: Messaging
- Authentication: off
- Routing: The skill the bot user will be assigned to
- Then select Next.
- If you wish to modify the look of the engagement, do so in the Studio. If you do not, select Next.
- On the engagement window library, you will need to create a new Engagement Window, so select + Add New.
- Click Add elements . Besides Welcome Message, click Edit.
- Set the welcome message to reflect the action the user needs to take. Earlier, we set the pattern to start the bot interaction to be Start Chat for an interaction to be triggered. So for this example, we will set the Quick reply to Start Chat. When the user selects it, it is sent as a message to the bot and the bot starts the interaction.
You can use multiple quick replies in order to allow for a specific action (e.g having Billing, Sales, or Technical support) and set questions appropriate to those quick reply responses. -
You should then be able to press .
-
Then publish the campaign in order for the engagement to be displayed. You can do this by selecting on the campaign.
Tip: This is just a brief outline of the process to create an engagement. If you are having trouble or want to see the full details, go to the Creating Web Engagements article.
Next Step: Deploy the Bot
While you have created a bot, it will not work yet. It has not yet been connected to Live Assist for Dynamics 365, and it still needs some configuration.
Go to the Deploying a Bot article to continue the process. Only after you finish the steps in that article will your bot be functional.