dialogflow-cx

google dialogflow conditional response does not work


I have two Entity types (@name and @ surname) . If the customer can enter these two parameters I will send the flow to another page. is it possible can I do this with conditional response?

I wrote a simple code like below but It does not work. I get "true" as output even if I don't enter my surname

if ($session.params.name! = " ") OR ($session.params.surname != " ")
      'true'
    else
      'false'
    endif

Thank you.


Solution

  • Yes, you can accomplish this by creating a route with a condition.

    https://cloud.google.com/dialogflow/cx/docs/concept/handler#route

    https://cloud.google.com/dialogflow/cx/docs/concept/handler#cond

    A route may include an intent and/or a condition. The CX UI includes this feature as well as boolean logic to help achieve your desired outcome. Example condition using user defined session parameters

    Then you can define the fulfillment and transition as needed.