Skip to main content

Apply Agenda to Chatbot

Agenda is a scheduling system within Stella that will run a specific node for a member in a specific time. In simple words, it is a timer, when the countdown is finished, a message is sent.

You can apply Agenda to create a scheduled message, while the scheduled period and the response are all up to you. You can use the scheduled message for updating application status, confirming transaction, etc. To make your conversation flow more flexible, you can also remove the agenda and proceed to another tree node.

In this session, you will learn how to set up Agenda in Stella, and build a sample conversation flow that will send a scheduled reminder to idled users.

Expected Outcome

Imagine you have a chatbot for customer service. When a customer enters your conversation flow but does not move on to the next conversation for 5 minutes, you want to send a reminder message to encourage the idled user to proceed with the conversation flow.

Scheduled Message sent when User is Unresponsive
Scheduled Message sent when User is Unresponsive
Scheduled Message sent when User is Unresponsive
Scheduled Message sent when User is Unresponsive

Sample Tree Structure

Sample Tree Structure for Agenda
Sample Tree Structure for Agenda

Set up Agenda in a Tree Node

  1. Create the 1st tree node, name it as "Greetings". This is the entry point of your conversation flow. In this case, we will apply the Agenda to this tree node.

  2. Create a Response to greet the customer.

Create a Greeting Message
Create a Greeting Message
  1. Create a quick reply to let the user proceed.
Create Quick Reply in Greeting Message
Create Quick Reply in Greeting Message

Add Pre-action

  1. Add a new Pre-action, name it as "Agenda". Then input the following code. this.newAgenda creates an agenda for a member. The agenda will be executed at the specified time: the nextRunAt field for a single run, or the pattern field for multiple runs. The agenda would start counting down whenever a customer goes through this tree node.
return new Promise((resolve) => {
let nextRunAt = this.moment().add(5, "minutes").valueOf()
this.newAgenda({
member: this.member,
treeId: this.node.tree,
nodeCompositeId: "FPl8vZRflSPBU9XD",
nextRunAt,
tag: "reminder",
replace: true,
"meta": {
"coreVersion": "3.0" }
})
resolve()
})

Input Time

  1. Input a scheduled time. The number must be integers, and the units can be "minutes", "hours", "days" or "weeks", remember to keep the units in plural form. The minimum scheduled time allowed is 1 minute.
Input Agenda Time
Input Agenda Time

Input TreeID

  1. Input the TreeID of the tree that your scheduled message belongs to. If it is in the same tree, input "this.node.tree". If it is different tree, input the TreeID, for instance, "6054b3e99cfe3e84ee174e88".
Input TreeID
Input TreeID
tip

CompositeID is the unique ID for a tree node. We will edit the Composite ID later.

Input Tag

  1. The tag field is used for tagging the agenda. Input a tag for your agenda, let's name it "reminder". It can be used to identify this agenda for other actions. Then click "Save".
Input Tag
Input Tag

Replace Agenda

  1. The tag created can be used with the replace field which, when creating a new agenda with the replace field as true, will remove any old agendas with the same tag of the same member, and replace it with the new agenda.
Replace Agenda
Replace Agenda

Create Scheduled Message

  1. Create a new tree node, name it as "Scheduled Message". We will create the reminder message in this tree node.

  2. Create a response or a follow-up question for your customer who is unresponsive for a specific period of time.

Create Scheduled Response
Create Scheduled Response
  1. Create two quick replies of "Yes" and "No".
Create Scheduled Response
Create Scheduled Response
  1. If needed, you can also bring your customer back to the normal conversation flow. In this case, you can create a global node, and redirect to the conversation if the customer selects "Yes" for the follow-up question.
Redirect to Converseation
Redirect to Converseation

Input CompositeID

  1. Copy the Composite ID of the your scheduled message node.
Copy Composite ID
Copy Composite ID
  1. Head to the node where you set up the agenda, then select Pre-actions, replace the Composite ID with the new one. Now the agenda will trigger the Scheduled Message when the timer stops.
Input Composite ID
Input Composite ID
  1. Now test your chatbot and see if you can get the expected outcome!

Remove Agenda

You want to send the reminder message to the idled users, without disturbing the responsive users. When the customer responds within the specific period of time, you want him to continue with the normal conversation flow. Therefore, you need to retract the reminder message by removing the agenda.

Expected Outcome

If the customer continues with the conversation flow within 5 minutes, the scheduled message will not be displayed.

Remove Agenda Result
Remove Agenda Result

  1. Create a new tree node following "Greetings", let's name it as "Conversation Continue". Then, create a Response for your customer who moves on with the conversation, which contains a question and three quick replies in this example.
Create Response
Create Response
  1. Add a new trigger to "Conversation Continue". Then this node would be triggered when the customer selects "Know more about us".
Create a Payload Trigger
Create a Payload Trigger

Add Post-action

  1. Create a new Post-action in this node, let's name it as "Remove Agenda", then input the following code. When this node is triggered within the scheduled time, the conversation flow continues and this post-action can remove the previous agenda.
return new Promise(async(resolve, reject) => {
await this.deleteMemberAgenda({
memberId: this.member._id,
tag: "reminder"
})
resolve()
})
  1. Input the agenda tag "reminder" you created in step 6, then the agenda with the same tag would be removed when this tree node is triggered.
Input Tag to Remove Agenda
Input Tag to Remove Agenda
  1. Test your chatbot and see if it can successfully remove the agenda.

Add Facebook Message Tag

In Facebook Messenger, businesses are encouraged to respond to their customers within 24 hours. If you decide to send a scheduled message to a customer after 24 hours, you need to include the specific Message Tag in the agenda.

Expected Outcome

An "Account Update" message is sent to notify the customer about change of application status.

Account Update
Account Update

  1. Go back to "Greetings" node, or any of your node that contains the agenda. Select Pre-action, add the following code to the agenda.
meta: {
messagingTag: "ACCOUNT_UPDATE",
messagingType: "MESSAGE_TAG"
}
  1. The field meta can be used to save information in the agenda. In meta, enter the Message Tag and Message Type. Click here to find other Message Tags that match with the nature of your message.
tip

Please make sure your message sent on Facebook Messenger follows the guidelines of Facebook and the Message Tag Policy, for example, avoid sending promotional content frequently and sending push message to audience who has unsubscribed or disagreed to receive.

Add Messaging Type & Tag
Add Messaging Type & Tag

WhatsApp Message Template

For agenda, the scheduled time can be more than 24 hours. If your chatbot is on WhatsApp, you are also bind by their 24-hour customer care window. If you decide to send a scheduled message 24 hours after the last response from the customer. You need to make use of WhatsApp Message Template.

First, you will need to submit your template to WhatsApp team for review. After that, you can come back to the response modal and select "Message Template" as a message type under the "WhatsApp Cloud" platform.

Message Template Response
Message Template Response