Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Dialogflow CX - transition to new page after webhook response

I am having problems getting Dialogflow to  transition to a page in the same flow after calling a webhook. It is called from a condition route on a page that prompts for a single parameter. The webhook response is getting some information from firestore  based on the value of that page parameter. It is tested and working by itself in the console agent simulator and with the DF messenger integration.

To configure the page transition I first tried simply setting the transition in the console. However this does not work.

While I can't find this clearly documented, I am wondering if you must handle the transition as part of the WebhookResponse witb target_page.

I tested this approach, and can get it to work in the simulator. It transitions and gives an entry fulfilment from the new page.

But it doesn't work when testing with the messenger integration. The webhook is a Cloud Run Function, but it doesn't appear to be logging any errors to Cloud logging that would explain the different behaviour in the agent simulator vs the messenger integration.

So two questions -

1) can anyone confirm that when using a webhook response, it is mandatory to set the target_page for a transition in the response itself rather than configuring in the console

2) how can I troubleshoot the different behaviour I see when setting target_page in the webhook response (is it works in simulator but not in messenger integration).

Thanks!

 

 

 

Solved Solved
0 6 738
1 ACCEPTED SOLUTION

Hi @Joe_McFadden is a behavior that is not documented. The webhook call and the transition are different things. If your webhook injects this job_choice with another value rather than null then that route has to work.

Could you please send an screenshot of the component?

View solution in original post

6 REPLIES 6

@Joe_McFadden 
1, webhook doesnt have anything to do with a transition, remember that transitios happens after a condition is fullfilled, webhook is not condition.
2. in your webhook try to set some parameters into session context. And then use a validation for that parameter that can go to the next page.

Thanks @Mizar for your reply.

1. I may not have worded my question clearly enough. I have a condition route ($session.params.job_choice != null). That condition is fufilled successfully with a webhook response. I now want to transition to another page after that response.  Setting the transition in the route does not work with a webhook response. It does work with other types of fulfillment. Why is this and where is it documented?

Hi @Joe_McFadden is a behavior that is not documented. The webhook call and the transition are different things. If your webhook injects this job_choice with another value rather than null then that route has to work.

Could you please send an screenshot of the component?

@Mizar Apologies for slow reply.

The webhook doesn't inject the job_choice parameter, it is set by the user through form_filing. It is the only required parameter for this page. 

Joe_McFadden_1-1739888187063.png
There is then a condition route to match any non null value of job_choice

Joe_McFadden_0-1739888005126.png

The route fulfilment calls the webhook which is a Google Cloud function. The tag is set to the pageID of the next page in the flow to transition to after the webhook response.

Joe_McFadden_2-1739888313751.png

As noted in my original post, I first tried to set the transition in the route, but that doesn't work due to the undocumented behaviour you mention.

Instead I am setting the transition target_page as part of my webhook response. My problem is that I get different behaviour in the simulator vs df messenger integration. 

In both, the route is called and the webhook response returns the expected results.

But while in the simulator I then get a page transition as set in the webhook response, the transition does not take place in the provided DF messenger integration. I get the webhook message response without the transition.

I've logged the json response the webhook sends back to dialogflow CX and it is identical when testing in the simulator and the messenger integration. The JSON response format is as follows:

{
    "fulfillment_response": {
        "messages": [
            {
                "text": {
                    "text": [
                        "**Job Detailsr**\\n 
                         markdown formatted details of this job....\\n\\n"
                    ]
                }
            },
            {
                "image": {
                    "imageUri": "https://storage.googleapis.com/some-bucket/image_job.jpg"
                }
            }
        ]
    },
    "target_page": "projects/[[PROJECT_ID]/locations/[REGION]/agents/[AGENT_ID]/flows/[Flow_ID]/[Page_ID]"
}

So I don't understand why the transition to target_page works in the console simulator, but not in the chatbot integration.

I've spotted where I was going wrong - there was a small typo in the custom payload that I used as entry fulfilment the transition target_page.
Fixed and it is now displaying correctly in the messenger integration .
I thought I'd tested this with just a static response rather than a custom payload before I made my original post. But I must have forgot to save that change in the console during testing.

Thank you for your help @Mizar - I'll accept your earlier post as a solution to my first question, as you confirmed this was undocumented behaviour for a route that includes a webhook response.

if you need the code to inject values from webhook to the context let me know.