TL;DR
How to configure Dialogflow intents to recognize if the user user input contains the phrase "Search product:" and:
- If the input contains the phrase "Search product:" store everything after this phrase as "$session.parameter.prompt" and pass this parameter to PRODUCT_SEARCH webhook
- If the input doesn't contain the phrase "Search product:" store the whole user input as "$session.parameter.prompt" and pass this parameter to GENERAL_SEARCH webhook
Example conversation 1
(user): Hi
(bot): Hi, how can I help?
(user): Search product: Great computer MMORPG games
bot executes PRODUCT_SEARCH webhook with input: "Great computer MMORPG games" because the input contained "Search product:" phrase
(bot):
$session.params.PRODUCT_SEARCH[0].title
$session.params.PRODUCT_SEARCH[0].description
$session.params.PRODUCT_SEARCH[1].title
$session.params.PRODUCT_SEARCH[1].description
$session.params.PRODUCT_SEARCH[2].title
$session.params.PRODUCT_SEARCH[2].description
(bot): Is there anything else I can help you with?
(user): No thanks
(bot): Ok, glad to have helped!
FLOW END
Example conversation 2
(user): Hi
(bot): Hi, how can I help?
(user): What is the difference between an MMORPG and an RPG computer game?
bot executes GENERAL_SEARCH webhook with input: "What is the difference between an MMORPG and an RPG computer game?" because the input DID NOT contain "Search product:" phrase
(bot): $session.params.GENERAL_SEARCH.output
(bot): Is there anything else I can help you with?
(user): What are some of the best RPG computer games?
bot executes GENERAL_SEARCH webhook with input: "What are some of the best RPG computer games?" because the input DID NOT contain "Search product:" phrase
(bot): $session.params.GENERAL_SEARCH.output (2nd webhook call output)
(bot): Is there anything else I can help you with?
(user): No
(bot): Ok, glad to have helped!
FLOW END
My take
My take is that this is an example of dealing with a user intent (do a general or product search) and a string parameter (long sentence to search) at the same time.
I was able to get the bot to work by taking a user_input
parameter (@sys.any). Screenshots below:
The problem is that this solution isn't very elegant and doesn't utilize Dialogflow intents which would help especially if the user writes another prompt for a webhook.
Question:
Is it possible to move this solution to Dialogflow intents? Ideally the intent would:
- recognize if there was the "Search product:" phrase (easy to do)
- store the rest of the intent input as a parameter to be passed to a webhook (don't know how to do).
This second part puzzles me. Is there some way to store everything what the user entered for an intent as a parameter? Note that the search phrases can be COMPLETELY different so creating an entity and training data for it doesn't seem like the most efficient option. The training data also seems like an overkill given the fact that it's a simple yes/no use case if there is a "Search product:" phrase.