Skip to main content

Actions

A tree node can have Pre-actions and Post-actions whereas a global node can have Actions.

Pre-actions are executed before the responses are executed and sent, while Post-actions are executed after responses are executed and sent.

An Action is a Promise function that can be used for logics, internal database manipulation and external API calling. The member object can be retrieved and edited. You can use the resolve callback of the promise function to resolve an object with member as the key. Then, the member can be passed to subsequent nodes. The member details will be saved to the database after all related nodes have been executed.

For more details on advanced chatbot concept & usage, you may visit here.


Pre-action

Pre-action is the action you would like to perform BEFORE sending responses to users, such as saving specific tags to a member or collecting users' answers to build user profiles. In order to do so, you need to create tempData to store the relevant data in the user profile.

Example to save users' gender:

return new Promise((resolve) => {
this.member.botMeta.tempData.gender = this.messageEvent.data.text
resolve({
member: this.member
})
})

If you would develop Public Reply Chatbot for Facebook on WOZTELL, you could write the following pre-action to save the comment from each of your users.

Example to save users' comment:

return new Promise(async (resolve, reject) => {
const result = await this.savePostCommentAnalytics({
comment: this.messageEvent.data.text,
postId: this.messageEvent.data.post_id,
isMatched: true,
memberId: this.member._id,
fbId: this.member.fbId,
name: this.messageEvent.data.from.name,
channelId: this.member.channel,
appId: this.member.app,
})
resolve()
})
PropertyDescription
postIdIt represents the ID for your specific Facebook post.
isMatchedSet to "true" if it's the correct comment trigger; set to "false" if it's the wrong comment trigger.
this.member.fbIdIt represents a unique user ID for users who comment on post. It will only be created upon user comment.
nameIt represents the Facebook user name for users who comment on post. It will only be created upon user comment.

Post-action

Post-action is the action you would like to perform AFTER sending responses to users. We suggest to set one post-action as default: Save CompositeId. This would help you track the position of your users within the conversation flow so you could read their footprint and analyze for future targeting.

Example to save users' footprint:

return new Promise((resolve) => {
this.member.botMeta.nodeCompositeId = this.node.compositeId
this.member.botMeta.tree = this.node.tree
resolve({
member: this.member,
})
})
tip

In case you'd like to include a particular piece of data in the coming message response, you must use pre-actions to store the data first.


Create an Action

You can plan ahead your whole chatbot journey and create actions that help you collect user data in a separate page called: Actions.

  1. Click to edit a node in Bot Builder.

  2. Click "+ New Action" create a new pre-action.

  1. Name the action so that you can search and reuse it if needed. Then, select "Advanced".
  1. Apply the action code and "Save" the pre-action.
  1. Finally, "Save" the changes made to this node.

Advanced Chatbot Actions

Some useful chatbot actions could only be applied with some coding in the advanced mode of resource template. In order to make these functions more accessible to general users, WOZTELL has introduced a set of Advanced Chatbot Actions which are available to all users.

These advanced actions include:

  • "Save TempData"
  • "Subscribe"
  • "Unsubscribe"
  • "Enable Livechat"
  • "Disable Livechat"
  • "Change Language"
  • "Save member info to DataSource"
  • "Invoke API"
  • "Set Agenda"
  • "Remove Agenda"

Variables

The text field in the action can also support variables.