This article talks about setting parameter values. (Were you interested in how to pass parameters between intents?)
I got this question on my YouTube channel recently:
what is the correct way to modify parameters using v2 from webhook? When I change them inside “outputContexts” it works. But, what about an intent which is not using context?
This reminded me of something else I have wanted to write about. Did you know there are 4 ways to set parameter values in Dialogflow? Knowing these can sometimes get you around some Dialogflow constraints.
1 Entity extraction during intent mapping
When Dialogflow maps the user’s phrase to an existing intent, it will extract the appropriate entity values in the user phrase where it can. So this is one way that a parameter value is set in Dialogflow – via entity extraction.
2 Setting the value in the parameters table
In my Intro to Dialogflow course, I show you how to create a Quiz bot. After the quiz is complete, the quiz bot should be able to tell you your score on the quiz.
This means, when the “correct” answer intent fires, we should assign a score of 1 to the user’s training phrase. As you see, this isn’t a value which you can extract from the user’s answer, which means we need to explicitly set it. This can be done by simply setting the value of a param such as answer1 to either a 0 or 1 indicating wrong or correct answer.
3 Setting the value inside an Event which triggers an intent
If you read my article on using an API call to Dialogflow to pass parameters to your conversation session, you can see that you can associate parameters with your event. Please note: the linked article is a very old one and uses API v1, so you will have to do your own translation to API v2 to use it now. But the basic idea is still the same – make an API call, send an event as part of the API call, and embed your parameters inside the event.
4 Setting parameters from your webhook
This brings us to the original question.
You can set parameter values from the webhook. But, you can only do it if it is set as part of an active context.
This website contains affiliate links. See the disclosure page for more details.
Check out my free YouTube courses Dialogflow CX Beginner Tutorial Dialogflow ES vs CX using a Decision Tree Bot Intro to NLU for technical non-programmers Better Dialogflow ES Bots Using the CTFS Framework Search the autogenerated transcripts of all my YouTube videos
"The magic key I needed as a non-programmer" The custom payload generator was the magic key I needed (as a non-programmer) to build a good demo with rich responses in DialogFlow Messenger. I've only used it for 30 minutes and am thrilled. I've spent hours trying to figure out some of the intricacies of DialogFlow on my own. Over and over, I kept coming back to Aravind's tutorials available on-line. I trust the other functionalities I learn to use in the app will save me additional time and heartburn. - Kathleen R Cofounder, gathrHealth