Setup bot to match Icebreakers & Persistent Menu

This guide helps you build a bot that responds to user choices. Whether they pick an icebreaker or a persistent menu option or any of the bot triggers match i.e comment on the post, comment on the live video, mention in the story or reply on the story, the bot will seamlessly switch to the relevant conversation flow.

Login to Factoreal, click on Conversations and then on “Launch Bot Portal”.

chatbot

This action will redirect you to the bot page in a new window.

Ensure that you have already created “Recent Incoming Msg” property in the bot. If not, you can create the property by following the steps below:

Click on Users → Switch to Properties tab → New Property

bot segments

Specify the name as “Recent Incoming Msg” and choose “Free Text” from the formats dropdown. Proceed by clicking on “Create”.

new property

Now that you have successfully created the custom property, you can proceed to Create/Edit bot.

Click on Bot Management → edit appropriate bot that is linked to Instagram channel.

bots list

Include a Script Node as the initial block in the bot by clicking on + Nodeand choosing “Script Node” from the options in the right-side menu.

 script node

Click on “Open the script editor”

script editor

Add below script in the Script Node editor & Save

var props = context.getCustomProperties();
var nodenameresponse = props.hasOwnProperty(“Recent Incoming Msg”) ? props[“Recent Incoming Msg”].value[0] : “”;
context.setResult({value: nodenameresponse});
next();

Click on add Node right after the Script node

script node

Add a “Conditional Logic” node from the options in the right-side menu.

script node

Specify the first Icebreaker or Persistent Menu (only Quick Reply) configured in Factoreal & click on Add Node

icebreaker text

Add corresponding bot flow that should be executed when user’s input match the value specified in above step.

icebreaker text match

Add conditional logic node to match the next Icebreaker or persistent menu option & enter the Icebreaker or persistent menu title

condition

Add corresponding bot flow that should be executed when user’s input match the value specified in above step.

preview

Repeat these steps to match all Icebreakers & Persistent Menu options and then Activate the bot.

If you want to match the bot triggers – Comment on the post, Comment on the live video, Reply on the story & Mention in the story then, add conditional logic nodes for each of these triggers & match “COMMENT_ON_POST”, “COMMENT_ON_LIVE_VIDEO”, “REPLY_ON_STORY”, “MENTION” keywords in conditional logic node accordingly.

Note: Facebook Messenger supports only “COMMENT_ON_POST” and  “COMMENT_ON_LIVE_VIDEO”.

For example if you want to trigger a bot when user comments on the post, then match “COMMENT_ON_POST” keyword in conditional logic node as shown below

comment-on-post

The final bot will appear as follows:

full-bot