How to set a custom platform in Dialogflow NodeJS Client

心已入冬 提交于 2019-12-04 15:12:52

sessions.detectIntent API has queryParams parameter which has a field called payload. That's where the "original payload" goes. The name of the platform goes into the source field of that structure. So your detectIntent call should look something like this:

sessionClient.detectIntent({
    session: sessionClient.sessionPath('<project_id>', '<session_id>'),
    queryInput: {
        text: {
            text: '<query>',
            languageCode: 'en-US'
        }
    },
    queryParams: {
        payload: {
            fields: {
                source: {
                    stringValue: '<platform>',
                    kind: 'stringValue'
                }
            }
        }
    }
})

I was able to simulate Slack integration call by using 'slack' as a platform name. I was also able to return a custom payload for a custom platform name. The payload is returned in queryResult.webhookPayload field.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!