Dialogflow sending image back to webhook fulfillment

1.2k views Asked by At

Am able to send image or Card back on /webhook route because sender is included in request object. But sender is not included in /ai (fulfillment webhook url).

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

But, my fulfillment route is /ai and the REQ body does not include the sender, so I always get this error where trying to send back anything but just text.

Error:  { message:

'(#100) Message cannot be empty, must provide valid attachment or text', type: 'OAuthException’,

1

There are 1 answers

0
Max Wiederholt On

Presuming you're using the NodeJS client library with Actions on Google, after you identify a user's intent, you can send an image in the following manner:

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',
  }))
})

For more info on getting started with Actions on Google, check out Google's codelabs,

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