Dialogflow: Respond based on values and other conditional responses

Saravanabalagi Ramachandran picture Saravanabalagi Ramachandran · Jul 22, 2018 · Viewed 9.6k times · Source

I have $dinetype variable obtained from the user.

enter image description here

But I would like to give response based on what value has been set in $dinetype variable. In addition to giving responses, I also need to set relevant context. How do I do this in DialogFlow?

enter image description here

if($Dinetype=='dineout') 
      ask ('which restaurant would you like to go to?')
      set_context ('awaiting-restaurant')
if($Dinetype=='takeaway') 
      ask ('When would you like to take away?')
      set_context ('awaiting-takeaway-time')

Is it programmable at all? Or is it possible to achieve something equivalent to the above in the UI?

Answer

corylulu picture corylulu · Apr 30, 2019

Late reply, but maybe someone will find this useful.

If the conditional response only needs to reference a single parameter value, then I figured out what you can do is utilize the Entity's "Reference Value" as the response you want to give for a particular set of Synonyms.

So you'd have an entity that looked like this:

Then, setup your intent like this, with a response of $Dinetype:

Then the end result will look like this:

And you can make whatever follow-up intent you need from there.

Down-side is Dinetype won't be as reusable. But I still think it beats writing a fulfillment webhook every time you need a simple conditional response.