Working with Commands
When building a multi-purpose chatbot, a common practice is to let your users run certain flows as a 'command'. A command is simply a specific word or phrase, usually prefixed with a forward slash ("/"), that matches the user input exactly and usually performs a specific task, like showing a help menu or escalating to live chat. Sometimes, you may want the user to be able to specify some additional information when they run the command. This is called the command "argument" and is any text after the command name.
In Flow XO you can easily implement commands using the New Command trigger.
The most important item to configure for a command is the Command Text. By convention, the Command Text should usually start with a forward slash ("/") but this is not required. Below are some sample user inputs that would trigger this command:
/remind /remind call mom @ 10am tomorrow /remind me of something
Unlike the New Message trigger, the command text must match the first part of the user input exactly. Anything after the command text is considered the command argument and is available as an output of the trigger for use in filters, messages or anywhere else variables can be used. For example, in the three sample inputs above, the Command Argument output would be as follows:
/remind - empty Command Argument, there is no text after the command name
/remind call mom@ 10am tomorrow - the Command Argument would be "call mom @ 10am tomorrow"
/remind me of something - the Command Argument would be "me of something"
Because an exact match is required, the following sample user inputs would NOT match this command:
/remindme /remind_me /reminder
Message types for commands work exactly the same as they do for the New Message trigger.
Direct Message - when Direct Message is checked the bot will respond to commands sent to the bot in a one on one private conversation
Direct Mention - when Direct Mention is checked, users can send commands to a bot that is in a group or channel they are in by referring to the bots user name, such as "@mybot /remind 10m call mom"
Overhear - when Overhear is checked, the bot will respond to a command in a group or channel even if the command is not addressed directly to the bot. For example if a user times "/remind 10m call mom" in a channel where the bot is installed.
Usually commands are treated like New Message triggers, in that they will react to a user message as long as the bot is listening for new messages, i.e. the bot is NOT waiting on the user to answer a question from a different flow, or in a live chat session. For example, if the user activated a flow that asked them for their e-mail address, and they responded "/remind 10m call mom" - normally the bot would interpret "/remind 10m call mom" as the users response to the question and give an error message that it isn't a valid e-mail address. However, if you set your command to be "High Priority" then it will ALWAYS execute your flow when the command is received, disregarding any open questions and even break through a live chat session with an agent.
Keep in mind that the bot will NOT automatically terminate an open conversation or live chat session if a high priority command is executed, it will just run the command flow in parallel with any other pending flow or live chat session. If you want the command to send messages to the user and the user might already be engaged in a conversation with another flow, you need to put a "Clear Open Conversations" step as the first action in your command flow. This action is part of the Flow XO Utilities integration: https://support.flowxo.com/article/240-utilities
That's all there is to commands! As always please let us know if you have any feedback, questions or difficulty with this or any other Flow XO feature at email@example.com