responsewebhooksdialogflow-cx

Manage webhook response as variable in the flow of Dialogflow CX


I've searched all over the internet, through documentation, and more, but I couldn't find information on whether it's possible to manage the response of the webhook in Dialogflow CX. I have a Page that calls a Google Cloud function as a webhook and retrieves a response like, for example:

res["fulfillment_response"]["messages"][0]["text"]["text"].append("response to handle")

I can display this response as Virtual Agent output, but I'm not sure how to manage it. For example, if the response is 'true,' I would like to route my page to one location, and if it's 'false,' I'd like to route it to a different one. Is this possible?

The only solution that I found is to redirect in another page in this way from the webhook:

res["target_page"] = "projects/[proj id]/locations/[company id]/agents/[agent id]/flows/[flow id]/pages/[page id]"

but I prefer the first option that I ask


Solution

  • My recommendation for that is at the same time that you are returning a text in the fulfillment object, you can create a session variable with the same content, with that, you can use that session variable anywhere on dialogflow CX!

    Here you have an example: https://cloud.google.com/dialogflow/cx/docs/how/webhook#webhook-set-session-nodejs