snlangsuan / facebook-bot-messenger Goto Github PK
View Code? Open in Web Editor NEWSDK of the Facebook Messenger Platform for Node.js
SDK of the Facebook Messenger Platform for Node.js
probably something simple i'm doing wrong as i had it appear once(only once and i made no major changes afterwards which is strange).
i'm trying to get the text from the users message but the message
object in bot.on(MessengerPlatform.Events.MESSAGE, function(userId, message)
returns:
TextMessageEvent { getType: [Function], setType: [Function], getPageId: [Function], getTime: [Function], getUserId: [Function], getSenderId: [Function], getRecipientId: [Function], getTimestamp: [Function], toJSON: [Function], toString: [Function], isTextMessage: [Function], isQuickReply: [Function], hasAttachments: [Function], getMessageSeq: [Function], getMessageId: [Function], getText: [Function] }
however using bot.getProfile(userId).then(function(data)
and then echoing the message produces
{"sender":{"id":"XXXXXXXXXXXXXX"},"recipient":{"id":"XXXXXXXXXXXXXX"},"timestamp":1514505450956,"message":{"mid":"mid.XXXXXXXXXXXXXXXXXXXXXXX","seq":XXXX,"text":"hello"}}
any ideas on where i might be going wrong? sorry for the noob question im quite new to javascript/nodejs
Hi, there:
The send messages api seem will be failed without the messaging_type property after May 7, 2018
so... it no problem using this repository?
https://developers.facebook.com/docs/messenger-platform/send-messages/#messaging_types
validationToken: ''
appID: '',
what is validation token.
Is appId = facebook app id in developer console or bot agent id in dialogflow console.
Would you consider providing support for handover protocol?
I'd be happy to contribute some work:
messaging_handovers
and standby
webhooksWhen using handover protocol, we need to subscribe to the messaging_handovers
and standby
webhooks.
Currently the package only supports the messaging
webhook:
I can contribute with a PR that helps accept the two types of webhooks and also provide the related helper methods:
Unfortunately your package was not findable on npm. Published it again with v. 1.0.9.
Was this an accident or on purpose?
I tested with your sample code. And it is not working.
var element1 = new MessengerPlatform.ListElementTemplateBuilder('Classic Black T-Shirt', 'https://peterssendreceiveapp.ngrok.io/img/black-t-shirt.png', '100% Cotton, 200% Comfortable');
element1.setDefaultAction('https://peterssendreceiveapp.ngrok.io/view?item=102', 'https://peterssendreceiveapp.ngrok.io/', true, URLButton.HEIGHT_RATIO.TALL)
.addURLButton('Buy', 'https://peterssendreceiveapp.ngrok.io/view?item=102');
var element2 = new MessengerPlatform.ListElementTemplateBuilder('Classic Gray T-Shirt', 'https://peterssendreceiveapp.ngrok.io/img/gray-t-shirt.png', '100% Cotton, 200% Comfortable');
element2.setDefaultAction('https://peterssendreceiveapp.ngrok.io/view?item=103', 'https://peterssendreceiveapp.ngrok.io/', true, URLButton.HEIGHT_RATIO.TALL)
.addURLButton('Buy', 'https://peterssendreceiveapp.ngrok.io/shop?item=103');
var template = new MessengerPlatform.ListTemplateBuilder();
template.isLargeTopElement(true)
.addElement(element1)
.addElement(element2)
.addPostbackButton('View More', 'USER_DEFINED_PAYLOAD');
var builder = new MessengerPlatform.AttachmentMessageBuilder(template);
bot.sendMessage(userId, builder)
It showed "URLButton is not defined"
So, i changed "URLButton.HEIGHT_RATIO.TALL" to "tall". And, it still not working.
Hi,
I am encountering this error, i followed the documentation on how to use it with Express but still get this error. Am i missing something? I am using the latest package version
Error: Can't render headers after they are sent to the client
at ServerResponse.writeHead (_http_server.js:214:15)
at BotMessenger.handleGETRequest (path\node_modules\facebook-bot-messenger\li
b\botmessenger.js:160:21)
at Server.httpRequest (path\node_modules\facebook-bot-messenger\lib\botmessen
ger.js:42:22)
at emitTwo (events.js:130:20)
at Server.emit (events.js:213:7)
at parserOnIncoming (_http_server.js:602:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
At line 140 and onwards, the Messenger
object is referenced. However, it is undefined.
Postback does not work anymore. It wont trigger
It seems there is an error in botmessenger.js line 161.
After writeHead, the headers are baked in and you can only call res.write(data), and finally res.end(data).
Since you don't include a return after line 159, the writeHead function is called again after the response is completed, leading to the Can't render headers after they are sent to the client
error.
Hi Guys, wonderful node module, I have one problem, I cannot for teh life of me work out how to send a template, I can get it built, but cannot figure out how to send it
I have tried passing the builder construct into all the bot.sendxxx and cannot see a senbd for templates ..
I know its probably obvious, but HELP!!
Many thanks
MArk
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.