Skip to content

Commit

Permalink
Added support for referral event
Browse files Browse the repository at this point in the history
  • Loading branch information
Charca committed Mar 28, 2017
1 parent 8065565 commit df179c5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- Support for [referral event](https://developers.facebook.com/docs/messenger-platform/referral-params).

## [1.0.10] - 2017-03-27
## Added
### Added
- Added `sendListTemplate` method.
- Added `imageAspectRatio` option to `sendGenericTemplate` method.

## Changed
### Changed
- Small change to how we call the `listeningAnswer` in Conversations to fix nexted `convo.ask()` not firing. (See #11).

## [1.0.9] - 2017-03-16
Expand All @@ -23,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Added generic error message for when Messenger's API responds with an 'error' node.

[Unreleased]: https://github.com/Charca/bootbot/compare/v1.0.10...HEAD
[1.0.10]: https://github.com/Charca/bootbot/compare/v1.0.9...v1.0.10
[1.0.9]: https://github.com/Charca/bootbot/compare/v1.0.8...v1.0.9
[1.0.8]: https://github.com/Charca/bootbot/compare/v1.0.7...v1.0.8
2 changes: 2 additions & 0 deletions lib/BootBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,8 @@ class BootBot extends EventEmitter {
this._handleEvent('read', event);
} else if (event.account_linking) {
this._handleEvent('account_linking', event);
} else if (event.referral) {
this._handleEvent('referral', event);
} else {
console.log('Webhook received unknown event: ', event);
}
Expand Down
21 changes: 21 additions & 0 deletions test/BootBot.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,27 @@ describe('BootBot', () => {
expect(spy.calledWith(expected)).to.equal(true);
});

it('emits a referral event', () => {
const callback = sinon.spy();
const event = {
"sender": {
"id": "USER_ID"
},
"recipient": {
"id": "PAGE_ID"
},
"timestamp": 1458692752478,
"referral": {
"ref": "MY_REF",
"source": "SHORTLINK",
"type": "OPEN_THREAD"
}
};
bot.on('referral', callback);
bot._handleEvent('referral', event);
expect(callback.calledWith(event)).to.equal(true);
});

describe('Checkbox Plugin support', () => {
it('uses the user_ref param as the recipient when replying to a checkbox authentication event', () => {
const spy = sinon.spy(bot, 'sendMessage');
Expand Down

0 comments on commit df179c5

Please sign in to comment.