broidHQ / integrations

Connect your App to Multiple Messaging Channels with the W3C Open standard.
https://www.broid.ai
GNU Affero General Public License v3.0
746 stars 83 forks source link

Messenger: FB API sends expects non-empty string for image title #137

Open m90 opened 7 years ago

m90 commented 7 years ago

Overview

Steps to Reproduce

  1. Start application with settings
  2. Send message

Use the messenger integration to send an image like:

{
  type: 'Image',
  url: 'http://example.net/image.jpg'
}

Observed

Facebook API responds with:

error: 400 - {"error":{"message":"(#100) Param [elements][0][title] must be a non-empty UTF-8 encoded string","type":"OAuthException","code":100,"fbtrace_id":"F8DlzRhbyZE"}}

Expected

The integration should send an image.

It looks like the empty string in the helpers cannot be used as a fallback value. Maybe the key needs to be omitted in that case?

killix commented 7 years ago

It's expected, Media title is mandatory by facebook API. One workaround is to add a piece of code to generate via the URL a title for the media. look here https://github.com/broidHQ/integrations/pull/144/files

m90 commented 7 years ago

I really have no clue how it is done, but when you use api.ai to hook into Messenger, you can send images without any sort of text attached. Don't know if that's feasible in this context though.

killix commented 7 years ago

You right, API.ai use the Image FB template for the attachment. I did the fix to use this template when the name if not fill. Otherwise, i use the generic template.