When you create Quick Replies as part of a passage, the Quick Reply text is limited to 20 characters. You can add a script to your chatbot like the example below to create a custom Quick Reply longer than 20 characters. When you add the script to a passage, you define the custom Quick Reply text.
To add a custom Quick Replies script to your chatbot:
- Select your team and chatbot.
- In the Create menu, click Scripts.
- Click +Script.
- Select to create the script From blank.
- Type a Script Name to describe the script.
- Click Create.
- In the Parameters section, create five String parameters:
- qrTitle1, with a description Text of first Quick Reply.
- qrPassage1, with a description Passage ID of first Quick Reply.
- qrTitle2, with a description Text of second Quick Reply.
- qrPassage2, with a description Passage ID of second Quick Reply.
- qrMsg, with a description Text message to send with Quick Replies.
- In the Javascript Code section, copy and paste the example script below.
- Click Save.
Add the script to a passage
To use the custom Quick Replies script:
- Open the passage where you want to send the custom Quick Replies.
- Add a script to the Bot Message.
- Configure the script parameters with:
- The text of the Quick Replies you want to send.
- The Passage IDs the Quick Replies should go to.
You can get the Passage ID of a passage from the passage menu in the conversation canvas. - The text message to send with the Quick Replies.
- Click Save.
Example script
const qrTitle1 = params.qrTitle1
const qrPassage1 = params.qrPassage1
const qrTitle2 = params.qrTitle2
const qrPassage2 = params.qrPassage2
const qrMsg = params.qrMsg
const quickReplies = [
{
text: qrTitle1,
nextPassage: {
conversationId: '',
passageId: qrPassage1,
resumeConversation: false,
resumeLastConversation: false,
},
},
{
text: qrTitle2,
nextPassage: {
conversationId: '',
passageId: qrPassage2,
resumeConversation: false,
resumeLastConversation: false,
},
},
];
const options = {
quickReplies
}
await bot.channel.sendTextMessage(qrMsg, options);
done();
The example script does the following to create two custom Quick Replies:
- Takes the custom text to use in the Quick Replies from the script parameters.
These parameters will be given values when a creator adds this script to a passage. - Takes the Passage ID of the passage each Quick Reply should go to from the script parameters.
- Takes the text message to send with the Quick Replies from the script parameters.
- Creates an array of two Quick Reply objects using the custom text and passage IDs.
- The passage each Quick Reply should lead to is set using the Passage Locator object inside the Quick Reply.
- Adds that Quick Replies array to an options object.
- Sends a chatbot message with the message to send and the options object.
Comments
Article is closed for comments.