Beta Advanced Keywords
Sophie Barfield avatar
Written by Sophie Barfield
Updated over a week ago

Advanced keywords enable you to create a much wider variety of combinations for keyword triggers. For example, if a user types 'data' and 'policy', the bot will reply with a message you've created on data policies. If the user types in just 'policy' but not 'data', then the bot will just reply with a message about just policies.

We've written down a few examples of the sort of things you can do with advanced keywords. The interface still needs a lot of work to be user friendly but we hope you can make use of the beta capabilities in the meantime.

Recreating IS and CONTAINS

When creating expressions, we can either say that the user input contains a particular word, or that the user input is a particular word.  In order to check this, use these functions (copy and paste the italic part):  

IS: is("policy", input) - where “policy” is the word you’d like to check for, and input represents what the user has typed into the bot.  Both “policy” and the input are passed into the is function and compared with each other.  If input is a perfect match for “policy” then this function returns true, which means the message associated with the advanced keyword is sent.

CONTAINS: contains("policy", input) -  where “policy” is the word you’d like to check for, and input represents what the user has typed into the bot.  Both “policy” and the input are passed into the is function and compared with each other.  If input is contains the word “policy” then this function returns true, which means the message associated with the advanced keyword is sent. Note that the word input should always be kept as input, as that’s what we use internally to represent what the user typed into the bot.

Examples

Example input: “Are there any in depth documents on our diversity policy?”

Advanced keyword: contains("documents", input) && contains("diversity", input) 

Bot reply: “Here are some documents that go into detail about our diversity policy”

Explanation: Here we’re saying that what the user typed into the bot must contain both “documents” and “diversity”.  We can do this by putting the && between the contains functions which means “and”.  If we wanted the user to have additionally typed in “please” then we could add && contains("please", input).  Using && effectively lets you say “this, and this, and this...” etc.

-

Example input: “What is our diversity policy?”

Advanced keyword: contains("diversity policy", input) && !contains("documents", input) 

Bot reply: “Our diversity policy is....”

Explanation: Here we’re saying that what the user typed into the bot must contain “diversity policy” but not contain “documents”.  So, we’re using the && as before to say that “both these contains functions must ring true”.  However, in order to say that we don’t want “documents” in what the user’s typed, we use the exclamation mark! It’s effectively a short-hand way of saying “not this”.  So by saying !contains("documents", input) we’re saying “user input does not contain the word ‘documents’”.

Did this answer your question?