fbsamples / messenger-bot-samples

Messenger Bot Samples
Other
555 stars 441 forks source link

`${SERVER_URL}/` seems to be not resolving properly #24

Closed RohitBansal18 closed 7 years ago

RohitBansal18 commented 7 years ago

@schvenk @tcsapunaru

my code can be found https://github.com/RohitBansal18/chatbot

This is not a issue in the sample example bot. I am creating new bot and following example step by step but stuck at GET_STARTED only. pls help.

Heroku Console Log: at=info method=POST path="/webhook" host=insurancetravel-bot.herokuapp.com request_id=aa3a62e2-355b-402f-83bc-25e98b92e4e8 fwd="173.252.86.214" dyno=web.1 connect=1ms service=52ms status=200 bytes=196 protocol=https

{ data: { object: 'page', entry: [ [Object] ] } } { messagingEvent: { recipient: { id: '122775108435220' }, timestamp: 1507433054356, sender: { id: '1493046944115720' }, postback: { payload: '{"type":"GET_STARTED"}', title: 'Get Started' } } } Webhook postback Received Successfully sent message to messages endpoint: {"recipient_id":"1493046944115720"}

Failed calling Messenger API endpoint messages 400 Bad Request { message: '(#100) Invalid data', type: 'OAuthException', code: 100, error_subcode: 2018032, fbtrace_id: 'Eqhka4Fpv7G' } {} { recipient: { id: '1493046944115720' }, message: { attachment: { type: 'template', payload: [Object] } } }

amuramoto commented 7 years ago

It looks like you are using straight quotes instead of backticks. Your code has '${SERVER_URL}/' If you want to use ES6 template strings, you need to use backticks instead of straight quotes.

RohitBansal18 commented 7 years ago

Thanks @amuramoto for replying. However, I was using backticks only in original code and I tried again, it is giving same error.

I found at URL: https://github.com/pimax/fb-messenger-php-example/issues/27 This error can be because of other issues which are not directly pointed out in logs

ghost commented 7 years ago

Looking at this it would seem the message is not well formed: Successfully sent message to messages endpoint: {"recipient_id":"1493046944115720"} If that's not it can you put a console log and JSON stringify the exact payload you are sending to the graph API?

RohitBansal18 commented 7 years ago

@tcsapunaru I started using "messenger profile" endpoint instead of "thread settings" endpoint for Domain White Listing, GET_STARTED, etc. now it works fine.

RohitBansal18 commented 7 years ago

thanks all...closing issue it is working fine now.