Search code examples
routeswebhooksdialogflow-cx

Route to a different page in a different flow from webhooks in Dialogflow CX


I would like to redirect to a page in another flow from a webhook. For instance, when a page calls a webhook, the webhook can redirect to a page in a different flow.

res["target_page"] = "projects/[id project]/locations/[id location]/agents/329b4fd2-6273-41b3-a113-ab2d53ae923b/flows/ead52edd-e7c2-46c8-af31-6c7b1e7c6678/pages/c563fc10-7058-4ae8-842e-d439560bdbe5"

when the webhook is triggered, I got this strange error:

enter image description here

It appears that when I select a Page, it defaults to the main flow even though I've specified the flow ID as 'ead52edd-e7c2-46c8-af31-6c7b1e7c6678'. I've tried entering different values, but it still considers the default flow '00000000-0000-0000-0000-000000000000'.

Is this a bug, and how can I correctly specify the flow?


Solution

  • In the webhookResponse, you can set the fulfillment_response and target_page fields to send a fulfillment response as well as transition to another page respectively. Here’s an example below:

    {
        targetPage: projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>/pages/<Page ID>,
        fulfillmentResponse: { 
            messages: [{ 
                text: [“Text response from webhook”],
            }] 
        } 
    }
    

    Here’s a sample result:

    enter image description here

    IMPORTANT: If it is in a different flow, you will have to specify the property targetFlow, you can use either targetFlow or targetPage but not both at the same time: https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/TransitionRoute

    When you transition to flow, it starts from the start page!