Create custom Quick Replies

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:

  1. Select your team and chatbot.
  2. In the Create menu, click Scripts.
  3. Click +Script.
  4. Select to create the script From blank.
  5. Type a Script Name to describe the script.
  6. Click Create.
  7. 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.
  8. In the Javascript Code section, copy and paste the example script below.
  9. Click Save.

Add the script to a passage

To use the custom Quick Replies script:

  1. Open the passage where you want to send the custom Quick Replies.
  2. Add a script to the Bot Message.
  3. 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.
  4. 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:

  1. 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.
  2. Takes the Passage ID of the passage each Quick Reply should go to from the script parameters.
  3. Takes the text message to send with the Quick Replies from the script parameters.
  4. 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.
  5. Adds that Quick Replies array to an options object.
  6. Sends a chatbot message with the message to send and the options object.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.