How to create a chatbot
Firstly, you are asked to provide the name of the project (you can if needed create a new project here) and the communication name.
The Chatbot design screen is then displayed:
At this screen, start creating the chatbot by dragging and dropping an interaction from the available interactions to the area at the left. When you do this, the right hand pane changes to show the properties of the interaction, which you can then edit.
For further information about interactions, see Interactions.
For example, if you drag across a Message interaction and call it "Message 1" with the text as "Hello user!", the screen will look like this:
The box in the bottom left allows you to resize the design area.
Click outside the message box to redisplay the Interactions pane.
When you have two or more interaction boxes, you can link them with a flow arrow to show the logical flow through the chat bot. To do this, select the first box, click one of the circles and drag a flow arrow to the next box. For example:
The various types of interaction are described below.
Message
Use the Message interaction to display a message to the user. Enter the message under Respond to User.
If the chatbot starts with a Message, you should enter Start in the WHEN THE USER SAYS field. This ensures that the bot will start correctly.
You can also specify HTML code under Respond to User. To do this, click the HTML Editor slider. This HTML can include URLs within an embedded iframe, but see Iframe Source under Get My Bot for information about reviewing and testing these iframe links.
Question
Use the Question interaction to ask the user a question. Under Answers, you can specify the type of answer that this question expects, such as a month name. If the user's response does not match the answer type, they will be asked to reenter their response. You can also specify a variable name which will be used to hold the answer that the user enters.
If you select Set up Button/Quick Reply Answer as the Answer Type, under Analytics you can select the following:
- Track Buttons. This enables the tracking of button presses for analytics purposes.
- Satisfaction Gauge. This enables the user to record a satisfaction score for analytics purposes.
- Disable text input field (Web Client only). Selecting this means that the user must click an option and cannot enter text.
If the chatbot starts with a Question, you should enter Start in the WHEN THE USER SAYS field. This ensures that the bot will start correctly.
Link
Use the Link interaction to display a URL for the user to click.
Carousel
Use the Carousel interaction to display a number of images in a carousel view, where the user can move forward or backward around the carousel.
Each image and associated action is defined in a card. For each card, you need to load an image and define the action to be taken when the user clicks on that image.
Action
Use the Action interaction to perform a defined action, such as setting a variable. The Details and Settings tabs are used to provide details of the action. Context-sensitive help is provided for some of these details.
Clearing the chat
There is a programmatic method to add a Clear Chat button to a chatbot. When the user presses this button, all chat history is cleared. This is particularly useful in a situation where multiple users are using the same device and you don't want a new user to see the chat history of the previous user.
The following sample JavaScript code creates a Clear Chat button:
var client = converseChatLoader({...});
client.on("show", function () {
var webClient = this;
var clearChatButton = document.createElement('button');
clearChatButton.style.marginTop = "50px";
clearChatButton.style.width = "360px";
clearChatButton.style.height = "75px";
clearChatButton.innerText = "Clear chat";
clearChatButton.onclick = function() {
webClient.processClearChat();
}
document.body.appendChild(clearChatButton);
});
The key line is:
webClient.processClearChat()
This clears the chat. The remaining code customizes the Clear Chat button.
The button created by the above code looks like this:
When the user clicks the Clear chat button, the chat history is cleared.
Image
Use the Image interaction to display an image. You need to specify the filename of the image, a Title and a Description.
Go To Bot
Use the Go To Bot interaction to go to another specified chatbot.
Send Email
Use the Send Email interaction to send an email with a specified subject line to one or more email addresses. The content of the email will be the transcript of the chat.
To specify multiple email addresses, use a comma separated list, or alternatively you can use a variable. You can also use a variable for the subject line.
Send Attachment
Use the Send Attachment interaction to send an attachment to the user via the chatbot. A static file can be attached manually by browsing for it (or using drag and drop); alternatively, you can use the Communicate API. For the API call, you need to specify the endpoint, the authorization and the content type; you can also use variables to customise exactly which file is sent.
Advanced Settings
You can select Advanced under Questions, Messages, Carousels, Actions.
Requires Account Linking - when this is selected, the user must pass through authentication to reach that interaction. If the user is not authenticated, you can specify to which part of the chatbot the flow should proceed.
Transaction Tag - this is added only for logging purpose. It allows you to see how many people start a specific part of the conversation and how many reach its end. For example, a chatbot could enable the user to get an insurance quote, but they must first answer five questions. In the first interaction for that questionnaire, you could add a Transaction Tag "quote" and in the last interaction you could add the same tag "quote" and mark Transaction End. In reporting, you can see how many people started this part of the chatbot, and how many reached its end. For further information, see Grouping interactions into transactions.
Run Action - you can select the action that will be run after a message or question and before the next interaction (if one is set up).
Send to User (Random Selection) - You can add a number of phrases using the Response Text box. Communicate will then select one of these phrases at random instead of the original message. For example, with greeting messages, you could specify one greeting but then add add a number of alternative greetings under Send to User. This makes the bot appear more human, as it does not always give the same greeting.
Bot Settings
If you click Bot Settings, a menu is displayed at the left:
- Bot Settings. Allows you to specify various settings for the chatbot, such as a description, the timeout (how many hours of inactivity cause the conversation to end) and an encryption key (if required).
- Language. See Language settings.
- Integration.
Security
The Security option under Bot Settings allows you to specify the allowed origins, that is, a list of domains that are allowed to access the web client for this bot. If nothing is entered here (the default), all domains can access the web client for the bot.
Language settings
If you click Bot Settings, the following options are available in the Language section:
Defaults
Under Language, you can define the language being used for chat bots. The default setting is Detect language, which detects the browser's language setting.
Quick Replies
Allows you to define quick replies, that is, replies that the bot will always make on receipt of the specified text (if it is not waiting for the answer to a question).
NLU
Click this option to enable the NLU (Natural Language Understanding) functionality. There are two elements to this functionality: Intents and Entities. Select the appropriate tab as shown below:
Intents
Allows you to specify Intents for NLU functionality. If you click Create intent, the following screen is displayed:
An Intent allows the system to better determine the user's intention. This is carried out by specifying a number of Utterances that correspond to the same intention. For example, an Intent could be called "car rental" and the Utterances could be "rent a car", "car hire" and "book a car". If any of the utterances are entered exactly by the user, the system will find an exact match. If the text entered by the user is not an exact match for any utterance, the system attempts to find an NLU match using Amazon Lex.
This message is displayed in the chat preview when an exact math is found:
This message is displayed in the chat preview window when a match is found using NLU:
Once an Intent has been defined, it can be selected for a particular interaction from the Intent dropdown. Intents are specified at the team level, so once an Intent has been defined, it is available for all chat bots within that team.
When defining an Intent or an Utterance, you can specify a Language from the dropdown. This means, for example, that a French phrase could be entered as an Utterance and it would be related to an English phrase as the Intent. Remember to check the language being used for the chatbot itself (see the Language option under Defaults). If you require additional languages for the Utterances, contact Support.
You can include Entities in an Utterance by prefixing it with the @ symbol. When the @ symbol has been entered, the list of available entities is displayed; you can select one from the list or keep on typing to narrow down the options. If you hover over an entity name, a tooltip is displayed, giving some examples of the entity value.
If you have an Utterance containing an entity, when the user enters the entity value (or a synonym) as part of the chat, Communicate will automatically create a variable of the same name as the entity, with the value set to the value entered by the user (if the user enters a synonym, the variable contains the value corresponding to the synonym, not the synonym itself). This variable can then be used in the chat logic.
Entities
Allows you to specify Entities for NLU (Natural Language Understanding) functionality. If you click the Entities tab, the following screen is displayed:
An entity is a generic category that can contain many values. For example, the entity with a name Airport will have a number of airport names as values. There are a number of built-in entities, which cannot be edited. To create a new entity. click Create Entity; the following screen is displayed:
Enter the entity name, then as many entity values as required. Each entity value can also have several synonyms. For example:
In this example, the entity Plane has three values: Boeing 777, Boeing 767 and Airbus A320. 777 and triple seven are synonyms of Boeing 777. If a synonym is found in the chat, it maps to the corresponding value.
Entities can be used in the Utterance field for an Intent. Preceding the Utterance with @ will tell the system to look for an entity.
Get My Bot
When you have completed the design of a chatbot, you can select Get My Bot to obtain an HTML listing of the bot. There are also a number of options that you can set.
Clicking Copy code (under the Embed Code tab) will add the displayed HTML code to the clipboard so that it can be pasted into your website code. You should only select this when all options have been set and any iframe links tested.
The Managed Hosting tab allows you to specify the subdomain and CSS styling used for hosting the bot.
Iframe warning
If you link to URLs from within the bot using embedded iframes, the following message is displayed above the code:
Click the link on below to go to the following box, which has automatically been populated with the iframe links found in the bot:
You can edit the information in this box if required. You can also use wildcards (with a star character *) within the URL; for example, "https://*.google.com/".
You should test all iframes before publishing.
Options
This section has a number of options that determine the behavior of the bot. Each option has some explanatory text with it.
Chat statistics
For details of how to display various statistics relating to a chat bot, see Statistics for a chat communication.