Hi,
I have linked the routes with a webhook, so when an intent is detected the webhook is triggered and the webhook sends the response back to the dialogflow. I'm getting different types of messages on the Intent object as shown below, will you please help me understand how the webhook response should look like. I'm using Google Dialogflow C# client libraries to serialize the webhook response and pass it back.
Use case 1: "Unauthorized FulfillmentResponse": false
Use case 2: "ErrorCode": "INVALID_ARGUMENT", "ErrorMessage": "Error calling webhook Failed to parse webhook response"
I'm trying to pass back the below response
{
"FulfillmentResponse": {
"Messages": [
{
"Text": {
"Text_": [
"Hi"
],
"AllowPlaybackInterruption": false
},
"Payload": null,
"ConversationSuccess": null,
"OutputAudioText": null,
"LiveAgentHandoff": null,
"EndInteraction": null,
"PlayAudio": null,
"MixedAudio": null,
"TelephonyTransferCall": null,
"ResponseType": 0,
"Channel": "",
"MessageCase": 1
}
],
"MergeBehavior": 0
},
"PageInfo": null,
"SessionInfo": null,
"Payload": null,
"TargetPage": "",
"HasTargetPage": false,
"TargetFlow": "",
"HasTargetFlow": false,
"TransitionCase": 0,
"TargetPageAsPageName": null,
"TargetFlowAsFlowName": null
}
Thanks in advance.
I think the JSON properties are malformed, I could not find any Text_ property in the spec. I would suggest to check the API Spec: https://cloud.google.com/dialogflow/cx/docs/reference/rest/v3/WebhookResponse
Newtonsoft Json serialization is not working and causing these issues. I had to use Google.Protobuf JsonFormatter to format the C# object and pass it back. Here is the code to serialize C# object WebhookResponse.
var webhookResponse = new WebhookResponse();
var fulfillmentResponse = new FulfillmentResponse();
fulfillmentResponse.Messages.Add(new ResponseMessage
{
Text = new ResponseMessage.Types.Text
{
Text_ = { responseText }
}
});
webhookResponse.FulfillmentResponse = fulfillmentResponse;
var jsonFormatter = new JsonFormatter(new JsonFormatter.Settings(true));
return jsonFormatter.Format(webhookResponse);
Exactly!
I had similar issues in Golang: https://github.com/xavidop/dialogflow-cx-webhook-go/blob/main/function.go
Best,
Xavi
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |