claudiajs / claudia-bot-builder

Create chat bots for Facebook Messenger, Slack, Amazon Alexa, Skype, Telegram, Viber, Line, GroupMe, Kik and Twilio and deploy to AWS Lambda in minutes
https://claudiajs.com/claudia-bot-builder.html
MIT License
1.84k stars 254 forks source link

Add setnotificationtype to facebooktemplate #83

Closed nbransby closed 7 years ago

nbransby commented 7 years ago

Support for Facebook's notification type: https://developers.facebook.com/docs/messenger-platform/send-api-reference

stojanovic commented 7 years ago

Awesome, thanks! Can you add that to the documentation too? Send a separate PR because I already merged this one.

jamesandersen commented 7 years ago

Hey @nbransby, I'm getting an error when attempting to use setNotificationType():

'access-control-allow-origin': '*',
pragma: 'no-cache',
'cache-control': 'no-store',
'facebook-api-version': 'v2.8',
expires: 'Sat, 01 Jan 2000 00:00:00 GMT',
'content-type': 'text/javascript; charset=UTF-8',
'x-fb-trace-id': 'XXX',
'x-fb-rev': '2828561',
vary: 'Accept-Encoding',
'x-fb-debug': 'iXXX',
date: 'Sun, 12 Feb 2017 06:11:54 GMT',
connection: 'close' },
body: '{"error":{"message":"(#100) Invalid keys \\"notification_type\\" were found in param \\"message\\".","type":"OAuthException","code":100,"fbtrace_id":"GOYNPgzx7m7"}}',
statusCode: 400,
statusMessage: 'Bad Request' }

My usage is as follows:

new fbTemplate.Text(`Hi ${userData.first_name}, What can I help you with today?`)
              .addQuickReply('Reply1', 'REPLY1')
              .addQuickReply('Reply2', 'REPLY2')
              .setNotificationType("NO_PUSH")
              .get();

Per the API docs it looks like notification_type needs to be a property of the root request object and the error message seems to indicate that it is being set as a property of the message object incorrectly.

Do you see something I'm doing wrong?

stojanovic commented 7 years ago

@jamesandersen it's fixed by https://github.com/claudiajs/claudia-bot-builder/pull/86, we were waiting for the test for it, but I'll merge it right now and add a test later.

jamesandersen commented 7 years ago

👍 Thanks!