Home / DialogFlow ES / Four ways to set parameter values in Dialogflow
DialogFlow ES

Four ways to set parameter values in Dialogflow

First published: Sep 2018 | Last updated: May 2022

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.

For example, in the example bot to capture user’s birthdate, you can see the value which is extracted inside the simulator. This is the most common way that a parameter is set in Dialogflow ES.

2 Setting the value in the parameters table

In the Quiz bot example, 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 score1 to either a 0 or 1 indicating wrong or correct answer.

Set score1 to 1 if the answer is correct
Set score1 to 0 if answer is incorrect

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.

For example, in my article on how to use webhook for slot filling, I use this concept to update the session-vars context.

<— End of article —>

This website contains affiliate links. See the disclosure page for more details. 
"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
"Much clearer than the official documentation to be honest"

Thanks a lot for the advice (of buying and following your videos)! They helped a lot indeed. Everything is very clear when you explain, much clearer than the official documentation to be honest 🙂

Neuraz T
Review for Learn Dialogflow CX
"I will strongly recommend this course because even I can learn how to design chatbot (no programming background)"

I think Aravind really did a great job to introduce dialogflow to people like me, without programming background. He organizes his course in very clear manner since I have been a college professor for 20 years. It is very easy for me to recognize how great Aravind’s course is! Very use-friend and very easy to follow. He doesn’t have any strong accent when he gives the lectures. It is so easy for me to understand. Really appreciate it.

Yes, I will strongly recommend this course because even I can learn how to design chatbot (no programming background) after studying Avarind’s course, you definitely can!

Ann Cai
Review for Learn Dialogflow ES

Similar Posts

  • I need to get user put from previous intent for example
    first intent- What is your firstName?
    2nd intent is- i got your firstName. what is your lastName.
    3rd intent – your Full name is firstName lastName.
    here I don’t know how to get firstName value

  • Hello, I’ve a followup intent which include a context that has a parameter ‘counter’ – with initial value set to zero. This follow-up intent makes a webhook call which receives the context along with the parameter “counter”: “0”. I’d like to know how to modify this parameter ‘counter’ value to say 5 from webhook (using python code) – any help will be much appreciated.

      • In puzzle-bot, user when says gimme a puzzle, a puzzle will be presented along with an instruction something like ‘do you need hint’. The user can keep asking for hint and more and more hints will be provided. I imagined two intents for this – ‘Provide_a_puzzle’ and it’s follow-up ‘Provide_a_puzzle – need_a_hint’. Further, each time a user asks for a hint, the follow-up intent will send a quizz_id and a hint_index to webhook which will send the hint for the next hint_index and set the new value of hint_index back to the bot. If user asks for another hint, the webhook now knows which hint to use by extracting the previously set value from the request, and increment the value again. Pls, let me know your thoughts.

      • I’m creating a bot for puzzle. User will be presented with a puzzle and then if they need hint, bot will provide one at a time. I decided to model this with two intents – ‘Supply_puzzle’ and a follow-up intent ‘Supply_puzzle – get_a_hint’. When user asks for puzzle, Supply_puzzle will contact webhook and a puzzle will be provided. Subsequent request for hint will be taken care of by the follow-up intent by calling a webhook. Since multiple users may play with same puzzle at the same time, it’s important that we keep track of the hint-index for each session. Further, if I added a param say, hint_index then each time webhook receives a req from follow-up intent we get the last hint_index. Then the webhook can supply the next hint as well as can modify the param value so that for next call from this intent give us the currect hint_index. Hope this provides the idea, why I need a way to update a param value from webhook