I have created a webhook using dialogflow-fulfillment to correctly return different data depending on the platform, including a custom one I created for another service. I've tested my webhook and know that if I change the originalDetectIntentRequest.source
to the platform used in my custom payload it works.
{
"payload": {
"jokes-api": {
"success": true,
"text": "These are some jokes",
}
},
"outputContexts": []
}
I am able to use dialogflow-nodejs-client-v2's sessions.detectIntent
to get a response, but the fullfilment comes back with the platform set as PLATFORM_UNSPECIFIED
, and not the custom payloads I want.
[{
"responseId": "c56c462f-bb3b-434a-b318-3739f58e6f6d",
"queryResult": {
"fulfillmentMessages": [{
"platform": "PLATFORM_UNSPECIFIED",
"card": {
"buttons": [],
"title": "Jokes",
"subtitle": "These are some jokes",
"imageUri": ""
},
"message": "card"
}],
"queryText": "tell me a joke",
/* ... */
"intent": {
"name": "projects/my-jokes/agent/intents/56887375-3047-4993-8e14-53b20dd02697",
"displayName": "Jokes",
/* ... */
},
"intentDetectionConfidence": 0.8999999761581421,
}
}]
Looking at the logs for my webhook, I can see that the originalDetectIntentRequest
object is present, but source is not set.
{
"responseId": "c56c462f-bb3b-434a-b318-3739f58e6f6d",
"queryResult": {
"queryText": "tell me a joke",
"speechRecognitionConfidence": 0.9602501,
/* ... */
"intent": {
"name": "projects/my-jokes/agent/intents/56887375-3047-4993-8e14-53b20dd02697",
"displayName": "Jokes"
},
/* ... */
},
"originalDetectIntentRequest": {
"payload": {
}
},
"session": "projects/my-jokes/agent/sessions/12345"
}
How can I set the platform or source in dialogflow-nodejs-client-v2 to get the desired responses?