Skip to content

Commit

Permalink
added support for m.me params
Browse files Browse the repository at this point in the history
  • Loading branch information
miki2826 committed Nov 9, 2016
1 parent 8728d72 commit 6fdb1e6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,10 @@ botly.on("message", (sender, message, data) => {
*/
});

botly.on("postback", (sender, message, postback) => {
botly.on("postback", (sender, message, postback, ref) => {
/**
* where postback is the postback payload
* and ref will arrive if m.me params were passed on a get started button (if defined)
*/
});

Expand Down Expand Up @@ -345,12 +346,18 @@ botly.on("account_link", (sender, message, link) => {
* where link is the the object containing the status and authorization code
*/
});
botly.on("referral", (sender, message, ref) => {
/**
* where ref is the data in the m.me param
*/
});
```

### Change Log

### version 1.3.0
- support version 1.3 of messenger including the new list template
- support for referral params on m.me links

### version 1.2.0
- added support for webview height in web url button
Expand Down
11 changes: 10 additions & 1 deletion lib/Botly.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ Botly.prototype.handleMessage = function (req) {
_handleDelivery.call(this, message);
_handlePostback.call(this, message);
_handleAccountLinking.call(this, message);
_handleReferral.call(this, message);
_handleUserMessage.call(this, message);
_handleEcho.call(this, message);
}, this);
Expand All @@ -517,7 +518,15 @@ function _handleDelivery(message) {
function _handlePostback(message) {
if (message.postback || (message.message && !message.message.is_echo && message.message.quick_reply)) {
let postback = (message.postback && message.postback.payload) || message.message.quick_reply.payload;
this.emit('postback', message.sender.id, message, postback);
let ref = message.postback.referral;
this.emit('postback', message.sender.id, message, postback, ref);
}
}

function _handleReferral(message) {
if (message.referral) {
let ref = message.referral.ref;
this.emit('referral', message.sender.id, message, ref);
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "botly",
"version": "1.3.0",
"version": "1.3.1",
"description": "Simple Facebook Messenger Bot API",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 6fdb1e6

Please sign in to comment.