Dialogflow将图像发送回Webhook实现

时间:2018-11-05 13:37:34

标签: dialogflow fulfillment

因为发件人包含在请求对象中,所以能够通过/ webhook路由将图像或卡发送回去。但是发件人不包含在/ ai(实现Webhook网址)中。

request({
url: 'https://graph.facebook.com/v2.6/me/messages',
qs: {access_token:token},
method: 'POST',
json: {
    recipient: {id:sender},
    message: messageData,
}

但是,我的履行途径是/ ai,并且REQ正文不包含发送者,因此在尝试发回除文本以外的任何内容时,我总是会遇到此错误。

Error:  { message:

'(#100)消息不能为空,必须提供有效的附件或文字',   类型:“ OAuthException”,

1 个答案:

答案 0 :(得分:0)

假设您将the NodeJS client library与Google上的“ Actions”配合使用,确定用户的意图后,可以通过以下方式发送图像:

app.intent('Default Welcome Intent', conv => {
  conv.ask(new Image({
    url: 'https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/imgs/160204193356-01-cat-500.jpg',
    alt: 'A cat',
  }))
})

有关在Google上开始使用Actions的更多信息,请查看Google的代码实验室,

  1. Build Actions for the Google Assistant (Level 1)
  2. Build Actions for the Google Assistant (Level 2)