New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bootbot

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootbot - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

examples/messenger-profile-example.js

2

CHANGELOG.md

@@ -8,2 +8,4 @@ # Change Log

## [Unreleased]
### Added
- Support for [Messenger Profile API](https://developers.facebook.com/docs/messenger-platform/messenger-profile).

@@ -10,0 +12,0 @@ ## [1.0.11] - 2017-04-13

56

lib/BootBot.js

@@ -159,5 +159,13 @@ 'use strict';

sendThreadRequest(body, method) {
console.warning(`
sendThreadRequest: Dreprecation warning. Thread API has been replaced by the Messenger Profile API.
Please update your code to use the sendProfileRequest() method instead.`
);
return this.sendRequest(body, 'thread_settings', method);
}
sendProfileRequest(body, method) {
return this.sendRequest(body, 'messenger_profile', method);
}
sendTypingIndicator(recipientId, milliseconds) {

@@ -184,6 +192,7 @@ const timeout = isNaN(milliseconds) ? 0 : milliseconds;

setGreetingText(text) {
return this.sendThreadRequest({
setting_type: 'greeting',
greeting: { text }
});
const greeting = (typeof text !== 'string') ? text : [{
locale: 'default',
text
}];
return this.sendProfileRequest({ greeting });
}

@@ -196,6 +205,6 @@

}
return this.sendThreadRequest({
setting_type: 'call_to_actions',
thread_state: 'new_thread',
call_to_actions: [{ payload }]
return this.sendProfileRequest({
get_started: {
payload
}
});

@@ -205,14 +214,22 @@ }

deleteGetStartedButton() {
return this.sendThreadRequest({
setting_type: 'call_to_actions',
thread_state: 'new_thread'
return this.sendProfileRequest({
fields: [
'get_started'
]
}, 'DELETE');
}
setPersistentMenu(buttons) {
setPersistentMenu(buttons, disableInput) {
if (buttons && buttons[0] && buttons[0].locale !== undefined) {
// Received an array of locales, send it as-is.
return this.sendProfileRequest({ persistent_menu: buttons });
}
// If it's not an array of locales, we'll assume is an array of buttons.
const formattedButtons = this._formatButtons(buttons);
return this.sendThreadRequest({
setting_type: 'call_to_actions',
thread_state: 'existing_thread',
call_to_actions: formattedButtons
return this.sendProfileRequest({
persistent_menu: [{
locale: 'default',
composer_input_disabled: disableInput || false,
call_to_actions: formattedButtons
}]
});

@@ -222,5 +239,6 @@ }

deletePersistentMenu() {
return this.sendThreadRequest({
setting_type: 'call_to_actions',
thread_state: 'existing_thread'
return this.sendProfileRequest({
fields: [
'persistent_menu'
]
}, 'DELETE');

@@ -227,0 +245,0 @@ }

{
"name": "bootbot",
"version": "1.0.11",
"version": "1.0.12",
"description": "Facebook Messenger Bot Framework",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -20,3 +20,3 @@ <p align="center">

- Send automatic or manual **typing indicators**.
- Set threads such as a **persistent menu**, a **greeting text** or a **get started CTA**.
- Set your bot's properties, such as a **persistent menu**, a **greeting text** or a **get started CTA**.
- Subscribe to **received** and **read** events.

@@ -129,3 +129,3 @@

});
const askName = (convo) => {

@@ -138,3 +138,3 @@ convo.ask(`What's your name?`, (payload, convo) => {

};
const askFavoriteFood = (convo) => {

@@ -147,3 +147,3 @@ convo.ask(`What's your favorite food?`, (payload, convo) => {

};
const sendSummary = (convo) => {

@@ -652,17 +652,19 @@ convo.say(`Ok, here's what you told me about you:

### Threads
### Messenger Profile API
#### `.setGreetingText(text)`
[Facebook Docs](https://developers.facebook.com/docs/messenger-platform/thread-settings/greeting-text)
[Facebook Docs](https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text)
| Param | Type | Default | Required |
|:------|:-----|:--------|:---------|
| `text` | string | | `Y` |
| `text` | string or array | | `Y` |
Set a greeting text for new conversations. The Greeting Text is only rendered the first time the user interacts with a the Page on Messenger.
**Localization support:** `text` can be a string containing the greeting text, or an array of objects to support multiple locales. For more info on the format of these objects, see [the documentation](https://developers.facebook.com/docs/messenger-platform/messenger-profile/greeting-text).
#### `.setGetStartedButton(action)`
[Facebook Docs](https://developers.facebook.com/docs/messenger-platform/thread-settings/get-started-button)
[Facebook Docs](https://developers.facebook.com/docs/messenger-platform/messenger-profile/get-started-button)

@@ -679,5 +681,5 @@ | Param | Type | Default | Required |

#### `.setPersistentMenu(buttons)`
#### `.setPersistentMenu(buttons, [ disableInput ])`
[Facebook Docs](https://developers.facebook.com/docs/messenger-platform/thread-settings/persistent-menu)
[Facebook Docs](https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu)

@@ -687,5 +689,10 @@ | Param | Type | Default | Required |

| `buttons` | array of strings or objects | | `Y` |
| `disableInput ` | boolean | `false` | `N` |
Creates a Persistent Menu that is available at any time during the conversation. The `buttons` param can be an array of strings or button objects.
Creates a Persistent Menu that is available at any time during the conversation. The `buttons` param can be an array of strings, button objects, or locale objects.
If `disableInput` is set to `true`, it will disable user input in the menu. The user will only be able to interact with the bot via the menu, postbacks, buttons and webviews.
**Localization support:** if `buttons` is an array of objects containing a `locale` attribute, it will be used as-is, expecting it to be an array of localized menues. For more info on the format of these objects, see [the documentation](https://developers.facebook.com/docs/messenger-platform/messenger-profile/persistent-menu).
#### `.deletePersistentMenu()`

@@ -703,3 +710,3 @@

- How to organize your code using modules
- How to use threads to set a Persistent Menu or a Get Started CTA
- How to use the Messenger Profile API to set a Persistent Menu or a Get Started CTA
- How to get the user's profile information

@@ -706,0 +713,0 @@

@@ -314,2 +314,106 @@ 'use strict';

describe('Messenger Profile API', () => {
it('can set a greeting text', () => {
const spy = sinon.spy(bot, 'sendProfileRequest');
const text = 'Hello, world!';
const expected = {
greeting: [{
locale: 'default',
text
}]
};
bot.setGreetingText(text);
expect(spy.calledWith(expected)).to.equal(true);
});
it('can set the Get Started button', () => {
const spy = sinon.spy(bot, 'sendProfileRequest');
const callback = () => {};
const expected = {
get_started: {
payload: 'BOOTBOT_GET_STARTED'
}
};
// With a callback
bot.setGetStartedButton(callback);
expect(spy.calledWith(expected)).to.equal(true);
const payload = 'CUSTOM_GET_STARTED_PAYLOAD';
const expected2 = {
get_started: {
payload
}
};
// With a payload
bot.setGetStartedButton(payload);
expect(spy.calledWith(expected)).to.equal(true);
});
it('can delete the Get Started button', () => {
const spy = sinon.spy(bot, 'sendProfileRequest');
const expected = {
fields: [ 'get_started' ]
};
bot.deleteGetStartedButton();
expect(spy.calledWith(expected, 'DELETE')).to.equal(true);
});
it('can set the Persistent Menu', () => {
const spy = sinon.spy(bot, 'sendProfileRequest');
const buttons = [
{
title: 'My Account',
type: 'nested',
call_to_actions: [
{
title: 'Pay Bill',
type: 'postback',
payload: 'PAYBILL_PAYLOAD'
},
{
title: 'History',
type: 'postback',
payload: 'HISTORY_PAYLOAD'
},
{
title: 'Contact Info',
type: 'postback',
payload: 'CONTACT_INFO_PAYLOAD'
}
]
},
{
title: 'Go to Website',
type: 'web_url',
url: 'http://purple.com'
}
];
const disableInput = false;
const expected = {
persistent_menu: [{
locale: 'default',
composer_input_disabled: disableInput,
call_to_actions: buttons
}]
};
bot.setPersistentMenu(buttons, disableInput);
expect(spy.calledWith(expected)).to.equal(true);
});
it('can delete the Persistent Menu', () => {
const spy = sinon.spy(bot, 'sendProfileRequest');
const expected = {
fields: [ 'persistent_menu' ]
};
bot.deletePersistentMenu();
expect(spy.calledWith(expected, 'DELETE')).to.equal(true);
});
});
describe('Checkbox Plugin support', () => {

@@ -316,0 +420,0 @@ it('uses the user_ref param as the recipient when replying to a checkbox authentication event', () => {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc