botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Receiving an attachment using Facebook Bot

Open matheus208 opened this issue 10 years ago • 5 comments

I'm using NodeJS and I managed to get my Bot working with regular messages on Facebook Messenger (plain text).

However, when I send my location, picture or any sort of attachment, I don't get any messages on my listener, until it fails with :

at=error code=H12 desc="Request timeout" method=POST path="MY_PATH" host=MY_HOST request_id=XXX fwd="XXX.XXX.XX.XXX" dyno=web.1 connect=1ms service=30002ms status=503 bytes=0

Is this some sort of bug? One of the main features of my application involves receiving the user's location.

Thanks!

matheus208 avatar May 06 '16 19:05 matheus208

Facebook messenger API does not support LOCATION, it does support sending of attachments (image/audio/video) and random http urls

tomlm avatar May 08 '16 19:05 tomlm

When i tested their API, I managed to send my location as an attachment tomy Bot on the Messenger app for Android and I received, on my webhook, a message which had as an attachment a latitude & longitude JSON object with my location...

matheus208 avatar May 09 '16 17:05 matheus208

can you share what the JSON for that, because their documentation doesn't say anything about it

tomlm avatar May 09 '16 18:05 tomlm

according to me sending location from messenger --> Server is possible but reverse is not possible and facebook docs doesn't specify send attachment of type location location

here is the response you will get on your server when you send location from messenge {"mid":"mid.1468518839177:f227be07c85ec7cd84", "seq":592, "attachments":[ { "title":"foo's Location", "url":"https://www.facebook.com/l.php?u=https%3A%2F%2Fwww.bing.com%2Fmaps%2Fdefault.aspx%3Fv%3D2%26pc%3DFACEBK%26mid%3D8100%26where1%3D28.474949%252C%2B77.040625%26FORM%3DFBKPL1%26mkt%3Den-US&h=iAQHsdjXF&s=1&enc=AZPhoqUogTWmjpaP3hWyoL_gDwWo_3xDBQO__6z1oPPk2ST8q3qdIQQOciFDd5cZ43SNBqn386dX7ZOg8xyeMz3wabQgOsrse32YbeZN0F1GkA", "type":"location", "payload":{"coordinates":{"lat":28.474949,"long":77.040625}} } ] }

there is a trick to handle this problem by sending generic message follow this link How to send location from Facebook messenger platform?

LabN36 avatar Jul 14 '16 19:07 LabN36

I think that's right, BTW: we should be mapping the location information into the Entities[] array as a GeoCoordinate object.

tomlm avatar Jul 15 '16 01:07 tomlm