Skip to main content

Create Member Tagging/Remarks Command

You can always add a custom remarks/member tag to a user who requires a follow-up or special attention. The tag will allow your agent to pinpoint any marked user easily on Stella.

Please set up this command in the Slack Command Tree you've created in Step 2.1.

What is your Result?

  1. In the case that the agent needs to add a remarks to a user, they can do so by typing the @[bot] remarks command.
Missing Items Conversation on Facebook Messenger
Missing Items Conversation on Facebook Messenger
The agent add a custom member tag to the user by typing @[bot]remarks
The agent add a custom member tag to the user by typing @[bot]remarks
  1. Once the member tagging/remarks command is entered, the tag will be appeared on Stella's "Members" page.
You can check the custom member tag on Stella
You can check the custom member tag on Stella
note

Please remember to connect your Slack Channel on Stella before testing for the result.

Sample Tree Structure - Member Tagging/Remarks Command

Slack Command Tree Structure for Member Tagging/Remarks Command
Slack Command Tree Structure for Member Tagging/Remarks Command

You can click here to download the sample tree.


Getting Hands-on

Enter your Bot Builder and starting building your tree.

Create a Tree Node - Member Tagging/Remarks Command

  1. Create a tree node and name it as "Remarks Command".

  2. Create a Pre-action for saving the remarks with the following code:

return new Promise(async (resolve, reject) => {
try {
const match = /(remarks)\s(.*)/.exec(this.messageEvent.data.text)
const tag = match[2]
const memberTag = `[Slack] ${tag}`
let group
if (this.channel.exclusiveLiveChat === false) {
group = await this.getGroupByExternalId({
groupId: this.messageEvent.to,
type: this.channel.type,
channelId: this.channel._id,
})
} else {
group = await this.getGroupByExternalId({
adminExternalId: this.messageEvent.from,
groupId: this.messageEvent.to,
type: this.channel.type,
channelId: this.channel._id,
})
}
const member = await this.getMember({ memberId: group.member })
const newMember = await this.addMemberTag({
filter: {
_id: member._id,
},
patch: {
$addToSet: {
"tags": memberTag
}
},
withModifier: true,
option: { new: true }
})
if (newMember.ok === 1) {
this.member.addTag = true
this.member.slackTag = tag
}
resolve({
member: this.member
})
} catch (e) {
reject(e)
}
})
  1. Create a response for remarks sucessfully added message under Advanced > Response Object with the following code:
return new Promise((resolve) => {
if (this.member.addTag) {
resolve({
"type": "TEXT",
"text": `Remark [${this.member.slackTag}] is added.`
})
} else {
resolve()
}
})
  1. Save this Tree Node.

Create a Global Node - Member Tagging/Remarks Command Global

  1. Create a global node and then create a trigger with two conditions with the and operator:
Member Tagging/Remarks Command Trigger for Slack
Member Tagging/Remarks Command Trigger for Slack

First condition - at bot:

new RegExp(`<@${this.channel.info.botId}`).test(this.messageEvent.data.text)

Second condition - remarks command:

new RegExp("remarks", "i").test(this.messageEvent.data.text)
  1. Toggle Redirect to the tree node you have created for member tagging/remarks command.
Redirect to Slack Member Tagging/Remarks Command Tree Node
Redirect to Slack Member Tagging/Remarks Command Tree Node
tip

Before testing, please remember to update the tree and global node in the Slack Channel.

  1. Check and see if you can produce the expected outcome.