dialogflow / dialogflow-fulfillment-nodejs

Dialogflow agent fulfillment library supporting v1&v2, 8 platforms, and text, card, image, suggestion, custom responses
Apache License 2.0
598 stars 280 forks source link

Fails to parse default console messages with custom payload #153

Open slowtick opened 6 years ago

slowtick commented 6 years ago

Dialogflow Console allows to add Custom Payload to Default platform.

Webhook request for such an intent with custom payload in Default platform fails to parse with below exception.

Error: Platform can NOT be empty 
 at new Payload (/app/node_modules/dialogflow-fulfillment/src/rich-responses/payload-response.js:60:13)
 at Object.convertPayloadJson_ [as payload] (/app/node_modules/dialogflow-fulfillment/src/v2-agent.js:439:12)
 at consoleMessageList.forEach (/app/node_modules/dialogflow-fulfillment/src/v2-agent.js:374:64)
 at Array.forEach (<anonymous>)
 at V2Agent.getConsoleMessages_ (/app/node_modules/dialogflow-fulfillment/src/v2-agent.js:369:24)
 at V2Agent.processRequest_ (/app/node_modules/dialogflow-fulfillment/src/v2-agent.js:163:41)
 at new WebhookClient (/app/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:238:17)
 at APP_

Can we get support for custom payload with Default platform?

slowtick commented 6 years ago

Currently worked around by setting platform to 'PLATFORM_UNSPECIFIED' in request before initializing the WebhookClient

if (!request.body.queryResult.fulfillmentMessages)
    return;
request.body.queryResult.fulfillmentMessages = request.body.queryResult.fulfillmentMessages.map(m => {
    if (!m.platform)
        m.platform = 'PLATFORM_UNSPECIFIED';
    return m;
});
HannesSan commented 4 years ago

It is 2020 and the error persists. I have to remove the payload for the webhook call to not send an unhandled promise warning when there is payload

Sata-Chakra commented 2 years ago

I am facing the same issue. Has no one solved this yet ?