Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

botmaster

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

botmaster - npm Package Compare versions

Comparing version 3.0.8 to 3.1.0

679

api-reference/base-bot.md

@@ -1,49 +0,4 @@

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
<a name="BaseBot"></a>
### Table of Contents
- [BaseBot](#basebot)
- [constructor](#constructor)
- [sendMessage](#sendmessage)
- [sendMessageTo](#sendmessageto)
- [sendMessageTo](#sendmessageto-1)
- [sendMessageTo](#sendmessageto-2)
- [sendMessageTo](#sendmessageto-3)
- [sendTextMessageTo](#sendtextmessageto)
- [reply](#reply)
- [sendAttachmentTo](#sendattachmentto)
- [sendAttachmentFromUrlTo](#sendattachmentfromurlto)
- [sendDefaultButtonMessageTo](#senddefaultbuttonmessageto)
- [sendIsTypingMessageTo](#sendistypingmessageto)
- [sendCascade](#sendcascade)
- [sendTextCascadeTo](#sendtextcascadeto)
- [sendRawMessage](#sendrawmessage)
- [getUserInfo](#getuserinfo)
- [createOutgoingMessage](#createoutgoingmessage)
- [createOutgoingMessage](#createoutgoingmessage-1)
- [createOutgoingMessage](#createoutgoingmessage-2)
- [createOutgoingMessageFor](#createoutgoingmessagefor)
- [OutgoingMessage](#outgoingmessage)
- [addRecipientById](#addrecipientbyid)
- [addRecipientByPhoneNumber](#addrecipientbyphonenumber)
- [removeRecipient](#removerecipient)
- [addText](#addtext)
- [removeText](#removetext)
- [addAttachment](#addattachment)
- [addAttachmentFromUrl](#addattachmentfromurl)
- [removeAttachment](#removeattachment)
- [addQuickReplies](#addquickreplies)
- [addPayloadLessQuickReplies](#addpayloadlessquickreplies)
- [addLocationQuickReply](#addlocationquickreply)
- [removeQuickReplies](#removequickreplies)
- [addSenderAction](#addsenderaction)
- [addTypingOnSenderAction](#addtypingonsenderaction)
- [addTypingOffSenderAction](#addtypingoffsenderaction)
- [addMarkSeenSenderAction](#addmarkseensenderaction)
- [removeSenderAction](#removesenderaction)
## BaseBot
**Extends EventEmitter**
The class from which all Bot classes mus inherit. It contains all the base

@@ -53,6 +8,30 @@ methods that are accessible via all bot classes. Classes that inherit from

prepend the method name with an underscore; e.g. in botmaster-messenger:
\_getGetStartedButton
_getGetStartedButton
### constructor
**Kind**: global class
* [BaseBot](#BaseBot)
* [new BaseBot(settings)](#new_BaseBot_new)
* _instance_
* [.createOutgoingMessage(message)](#BaseBot+createOutgoingMessage) ⇒ <code>OutgoingMessage</code>
* [.createOutgoingMessageFor(recipientId)](#BaseBot+createOutgoingMessageFor) ⇒ <code>OutgoingMessage</code>
* [.sendMessage(message, [sendOptions])](#BaseBot+sendMessage) ⇒ <code>Promise</code>
* [.sendMessageTo(message, recipientId, [sendOptions])](#BaseBot+sendMessageTo) ⇒ <code>Promise</code>
* [.sendTextMessageTo(text, recipientId, [sendOptions])](#BaseBot+sendTextMessageTo) ⇒ <code>Promise</code>
* [.reply(incomingUpdate, text, [sendOptions])](#BaseBot+reply) ⇒ <code>Promise</code>
* [.sendAttachmentTo(attachment, recipientId, [sendOptions])](#BaseBot+sendAttachmentTo) ⇒ <code>Promise</code>
* [.sendAttachmentFromUrlTo(type, url, recipientId, [sendOptions])](#BaseBot+sendAttachmentFromUrlTo) ⇒ <code>Promise</code>
* [.sendDefaultButtonMessageTo(buttonTitles, textOrAttachment, recipientId, [sendOptions])](#BaseBot+sendDefaultButtonMessageTo) ⇒ <code>Promise</code>
* [.sendIsTypingMessageTo(recipientId, [sendOptions])](#BaseBot+sendIsTypingMessageTo) ⇒ <code>Promise</code>
* [.sendCascade(messageArray, [sendOptions])](#BaseBot+sendCascade) ⇒ <code>Promise</code>
* [.sendTextCascadeTo(textArray, recipientId, [sendOptions])](#BaseBot+sendTextCascadeTo) ⇒ <code>Promise</code>
* [.sendRawMessage(rawMessage)](#BaseBot+sendRawMessage) ⇒ <code>Promise</code>
* [.getUserInfo(userId)](#BaseBot+getUserInfo) ⇒ <code>Promise</code>
* _static_
* [.createOutgoingMessage(message)](#BaseBot.createOutgoingMessage) ⇒ <code>OutgoingMessage</code>
* [.createOutgoingMessageFor(recipientId)](#BaseBot.createOutgoingMessageFor) ⇒ <code>OutgoingMessage</code>
<a name="new_BaseBot_new"></a>
### new BaseBot(settings)
Constructor to the BaseBot class from which all the bot classes inherit.

@@ -62,10 +41,9 @@ A set a basic functionalities are defined here that have to be implemented

**Parameters**
- `settings` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** inheritors of BaseBot take a settings
object as first param.
| Param | Type | Description |
| --- | --- | --- |
| settings | <code>object</code> | inheritors of BaseBot take a settings object as first param. |
**Examples**
```javascript
**Example**
```js
// In general however, one can instantiate a bot object like this:

@@ -77,5 +55,39 @@ const bot = new BaseBotSubClass({ // e.g. MessengerBot

```
<a name="BaseBot+createOutgoingMessage"></a>
### sendMessage
### baseBot.createOutgoingMessage(message) ⇒ <code>OutgoingMessage</code>
createOutgoingMessage exposes the OutgoingMessage constructor
via BaseBot. This simply means one can create their own
OutgoingMessage object using any bot object. They can then compose
it with all its helper functions
This is the instance version of this method
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. The same object passed in with
all the helper functions from OutgoingMessage
| Param | Type | Description |
| --- | --- | --- |
| message | <code>object</code> | base object that the outgoing Message should be based on |
<a name="BaseBot+createOutgoingMessageFor"></a>
### baseBot.createOutgoingMessageFor(recipientId) ⇒ <code>OutgoingMessage</code>
same as #createOutgoingMessage, creates empty outgoingMessage with
id of the recipient set. Again, this is jut sugar syntax for creating a
new outgoingMessage object
This is the instance version of this method
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. A valid OutgoingMessage object with recipient set.
| Param | Type | Description |
| --- | --- | --- |
| recipientId | <code>string</code> | id of the recipient the message is for |
<a name="BaseBot+sendMessage"></a>
### baseBot.sendMessage(message, [sendOptions]) ⇒ <code>Promise</code>
sendMessage() falls back to the sendMessage implementation of whatever

@@ -85,116 +97,81 @@ subclass inherits form BaseBot. The expected format is normally any type of

**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object (see example)
- `message` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `sendOptions` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** options used for sending the message. e.g. ignoreMiddleware
| Param | Type | Description |
| --- | --- | --- |
| message | <code>object</code> | |
| [sendOptions] | <code>boolean</code> | an object containing options regarding the sending of the message. Currently the only valid options is: `ignoreMiddleware`. |
**Examples**
**Example**
```js
const outgoingMessage = bot.createOutgoingMessageFor(update.sender.id);
outgoingMessage.addText('Hello world');
```javascript
bot.sendMessage(outgoingMessage);
```
**Example**
```js
// The returned promise for all sendMessage type events resolves with
// a body that looks something like this:
{
raw: rawBody, // can be undefined (e.g. if rawBody is directly returned)
sentOutgoingMessage: // the OutgoingMessage instance before being formatted
sentRawMessage: // the OutgoingMessage object after being formatted for the platforms
raw: rawBody, // the raw response from the platforms received from sending the message
recipient_id: <id_of_user>,
message_id: <message_id_of_what_was_just_sent>
sentMessage: <sent_message_object>
}
// Some platforms may not have either of these parameters. If that's the case,
// the value assigned will be null or some other suitable value as the
// equivalent to Messenger's seq in Telegram.
// the value assigned will be a falsy value
```
<a name="BaseBot+sendMessageTo"></a>
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
### sendMessageTo
Bot class implementation of the \_\_sendMessage function. Each Bot class
has to implement this in order to be able to send outgoing messages.
**Parameters**
- `message` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `recipientId`
- `sendOptions`
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise that resolves in the body of the response from the platform\_\_sendMessage(rawUpdate) {}
### sendMessageTo
Bot class implementation of the \_\_formatOutgoingMessage function. Each Bot class
has to implement this in order to be able to send outgoing messages that start
off as valid Messenger message objects (i.e. OutgoingMessage objects).
**Parameters**
- `outgoingMessage` **[OutgoingMessage](#outgoingmessage)** The outgoingMessage object that
needs to be formatted to the platform standard (formatted out).
- `message`
- `recipientId`
- `sendOptions`
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise that resolves in the body of the response from the platform\_\_formatOutgoingMessage(outgoingMessage) {}
### sendMessageTo
Bot class implementation of the \_\_createStandardBodyResponseComponents
function. Each Bot class has to implement this in order to be able to
send outgoing messages using sendMessage. This function returns the standard
recipient_id and message_id we can expect from using sendMessage
**Parameters**
- `sentOutgoingMessage` **[OutgoingMessage](#outgoingmessage)** The OutgoingMessage object
before formatting
- `sentRawMessage` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** The raw message that was actually sent to
the platform after \_\_formatOutgoingMessage was called
- `rawPlatformBody` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the raw body response from the platform
- `message`
- `recipientId`
- `sendOptions`
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise that resolves in an object that contains
both the recipient_id and message_id fields\_\_createStandardBodyResponseComponents(
sentOutgoingMessage, sentRawMessage, rawPlatformBody) {}
### sendMessageTo
### baseBot.sendMessageTo(message, recipientId, [sendOptions]) ⇒ <code>Promise</code>
sendMessageTo() Just makes it easier to send a message without as much
structure.
**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)
- `message` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** NOT an instance of OutgoingMessage. Use
\#sendMessage if you want to send instances of OutgoingMessage
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `sendOptions` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** just options for sending.
| Param | Type | Description |
| --- | --- | --- |
| message | <code>object</code> | NOT an instance of OutgoingMessage. Use #sendMessage if you want to send instances of OutgoingMessage |
| recipientId | <code>string</code> | a string representing the id of the user to whom you want to send the message. |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
**Examples**
```javascript
**Example**
```js
// message object can look something like this:
message: {
// as you can see, this is not an OutgoingMessage instance
const message = {
text: 'Some random text'
}
bot.sendMessageTo(message, update.sender.id);
```
<a name="BaseBot+sendTextMessageTo"></a>
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
### sendTextMessageTo
### baseBot.sendTextMessageTo(text, recipientId, [sendOptions]) ⇒ <code>Promise</code>
sendTextMessageTo() Just makes it easier to send a text message with
minimal structure.
**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)
- `text` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `sendOptions` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** just options for sending.
| Param | Type | Description |
| --- | --- | --- |
| text | <code>string</code> | |
| recipientId | <code>string</code> | a string representing the id of the user to whom you want to send the message. |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
**Example**
```js
bot.sendTextMessageTo('something super important', update.sender.id);
```
<a name="BaseBot+reply"></a>
### reply
### baseBot.reply(incomingUpdate, text, [sendOptions]) ⇒ <code>Promise</code>
reply() Another way to easily send a text message. In this case,

@@ -204,26 +181,35 @@ we just send the update that came in as is and then the text we

**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)
- `incomingUpdate` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `text` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `sendOptions` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** just options for sending.
| Param | Type | Description |
| --- | --- | --- |
| incomingUpdate | <code>object</code> | |
| text | <code>string</code> | text to send to the user associated with the received update |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
**Example**
```js
bot.reply(update, 'something super important!');
```
<a name="BaseBot+sendAttachmentTo"></a>
### sendAttachmentTo
### baseBot.sendAttachmentTo(attachment, recipientId, [sendOptions]) ⇒ <code>Promise</code>
sendAttachmentTo() makes it easier to send an attachment message with
less structure.
**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)
- `attachment` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `sendOptions` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** just options for sending.
| Param | Type | Description |
| --- | --- | --- |
| attachment | <code>object</code> | a valid Messenger style attachment. See [here](https://developers.facebook.com/docs/messenger-platform/send-api-reference) for more on that. |
| recipientId | <code>string</code> | a string representing the id of the user to whom you want to send the message. |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
**Examples**
```javascript
**Example**
```js
// attachment object typically looks something like this:
const attachment = {

@@ -235,22 +221,29 @@ type: 'image',

};
bot.sendAttachmentTo(attachment, update.sender.id);
```
<a name="BaseBot+sendAttachmentFromUrlTo"></a>
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
### sendAttachmentFromUrlTo
### baseBot.sendAttachmentFromUrlTo(type, url, recipientId, [sendOptions]) ⇒ <code>Promise</code>
sendAttachmentFromUrlTo() makes it easier to send an attachment message with
minimal structure.
**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)
- `type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `sendOptions` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** just options for sending.
| Param | Type | Description |
| --- | --- | --- |
| type | <code>string</code> | string representing the type of attachment (audio, video, image or file) |
| url | <code>string</code> | the url to your file |
| recipientId | <code>string</code> | a string representing the id of the user to whom you want to send the message. |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
**Example**
```js
bot.sendAttachmentFromURLTo('image', "some image url you've got", update.sender.id);
```
<a name="BaseBot+sendDefaultButtonMessageTo"></a>
### sendDefaultButtonMessageTo
### baseBot.sendDefaultButtonMessageTo(buttonTitles, textOrAttachment, recipientId, [sendOptions]) ⇒ <code>Promise</code>
sendDefaultButtonMessageTo() makes it easier to send a default set of

@@ -260,120 +253,121 @@ buttons. The default button type is the Messenger quick_replies, where

**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)
- `buttonTitles` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)**
- `textOrAttachment` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** , if falsy, will be set to a
default text of "Please select one of:"
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `sendOptions` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
| Param | Type | Description |
| --- | --- | --- |
| buttonTitles | <code>Array</code> | array of button titles (no longer than 10 in size). |
| textOrAttachment | <code>string_OR_object</code> | a string or an attachment object similar to the ones required in `bot.sendAttachmentTo`. This is meant to provide context to the buttons. I.e. why are there buttons here. A piece of text or an attachment could detail that. If falsy, text will be added that reads: 'Please select one of:'. |
| recipientId | <code>string</code> | a string representing the id of the user to whom you want to send the message. |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
**Example**
```js
const buttonArray = ['button1', 'button2'];
bot.sendDefaultButtonMessageTo(buttonArray,
'Please select "button1" or "button2"', update.sender.id,);
```
<a name="BaseBot+sendIsTypingMessageTo"></a>
### sendIsTypingMessageTo
### baseBot.sendIsTypingMessageTo(recipientId, [sendOptions]) ⇒ <code>Promise</code>
sendIsTypingMessageTo() just sets the is typing status to the platform
if available.
based on the passed in update
i.e. it has no message_id (or it is null/undefined)
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)
**Parameters**
| Param | Type | Description |
| --- | --- | --- |
| recipientId | <code>string</code> | a string representing the id of the user to whom you want to send the message. |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
- `sendOptions` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?**
**Examples**
```javascript
// the returned value is different from the standard one. It looks something
//like this in this case:
{
recipient_id: <id_of_user>
}
**Example**
```js
bot.sendIsTypingMessageTo(update.sender.id);
// the returned value is different from the standard one. it won't have a message_id
```
<a name="BaseBot+sendCascade"></a>
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
### baseBot.sendCascade(messageArray, [sendOptions]) ⇒ <code>Promise</code>
sendCascade() allows developers to send a cascade of messages
in a sequence. All types of messages can be sent (including raw messages).
### sendCascade
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with an array of body objects
(see `sendMessage` example for one said object)
sendCascadeTo() allows developers to send a cascade of messages
in a sequence. All types of messages can be sent (including raw messages).
| Param | Type | Description |
| --- | --- | --- |
| messageArray | <code>Array</code> | of messages in a format as such: [{raw: someRawObject}, {message: some valid outgoingMessage}] |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage`. will only apply to non rawMessages. (remember that for rawMessages, outgoing middleware is bypassed anyways). |
**Parameters**
**Example**
```js
const rawMessage1 = {
nonStandard: 'message1',
recipient: {
id: 'user_id',
},
};
const message2 = bot.createOutgoingMessageFor(update.sender.id);
message2.addText('some text');
- `messageArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** of messages in a format as such:
[{raw: someRawObject}, {message: some valid outgoingMessage}]
- `sendOptions`
const messageArray = [{ raw: rawMessage1 }, { message: message2 }];
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
The returned value an in-place array of bodies received from the client platform
The objects of the array are of the same format as for standard messages
bot.sendCascade(messageArray);
```
<a name="BaseBot+sendTextCascadeTo"></a>
### sendTextCascadeTo
### baseBot.sendTextCascadeTo(textArray, recipientId, [sendOptions]) ⇒ <code>Promise</code>
sendTextCascadeTo() is simply a helper function around sendCascadeTo.
It allows developers to send a cascade of text messages more easily.
**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves with an array of body objects
(see `sendMessage` example for one said object)
- `textArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** of messages in a format as such: ['message1', 'message2']
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** just the id of the recipient to send the messages to.
- `sendOptions`
| Param | Type | Description |
| --- | --- | --- |
| textArray | <code>Array</code> | of messages. |
| recipientId | <code>string</code> | a string representing the id of the user to whom you want to send the message. |
| [sendOptions] | <code>object</code> | see `sendOptions` for `sendMessage` |
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
The returned value an in-place array of bodies received from the client platform
The objects of the array are of the same format as for standard messages
**Example**
```js
bot.sendTextCascadeTo(['message1', 'message2'], user.sender.id);
```
<a name="BaseBot+sendRawMessage"></a>
### sendRawMessage
### baseBot.sendRawMessage(rawMessage) ⇒ <code>Promise</code>
sendRawMessage() simply sends a raw platform dependent message. This method
calls **sendMessage in each botClass without calling formatOutgoingMessage
before. It's really just sugar around **sendMessage which shouldn't be used
calls __sendMessage in each botClass without calling formatOutgoingMessage
before. It's really just sugar around __sendMessage which shouldn't be used
directly.
**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise
- `rawMessage` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
| Param | Type |
| --- | --- |
| rawMessage | <code>Object</code> |
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise
<a name="BaseBot+getUserInfo"></a>
### getUserInfo
### baseBot.getUserInfo(userId) ⇒ <code>Promise</code>
Retrieves the basic user info from a user if platform supports it
**Parameters**
**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>Promise</code> - promise that resolves into the user info or an empty
object by default
- `userId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)**
| Param | Type |
| --- | --- |
| userId | <code>string</code> |
Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise that resolves into the user info or an empty
object by default
<a name="BaseBot.createOutgoingMessage"></a>
### createOutgoingMessage
sets up the app if needed.
As in sets up the endpoints that the bot can get called onto
see code in bot classes packages to see examples of this in action
Should not return anything
\_\_createMountPoints() {}
**Parameters**
- `message`
### createOutgoingMessage
Format the update gotten from the bot source (telegram, messenger etc..).
Returns an update in a standard format
**Parameters**
- `rawUpdate` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `message`
Returns **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** update\_\_formatUpdate(rawUpdate) {}
### createOutgoingMessage
\#createOutgoingMessage exposes the OutgoingMessage constructor
### BaseBot.createOutgoingMessage(message) ⇒ <code>OutgoingMessage</code>
createOutgoingMessage exposes the OutgoingMessage constructor
via BaseBot. This simply means one can create their own

@@ -383,11 +377,15 @@ OutgoingMessage object using any bot object. They can then compose

**Parameters**
This is the static version of this method
- `message` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** base object that the outgoing Message should be based on
**Kind**: static method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. The same object passed in with
all the helper functions from OutgoingMessage
Returns **[OutgoingMessage](#outgoingmessage)** outgoingMessage. The same object passed in with
all the helper functions from OutgoingMessage
| Param | Type | Description |
| --- | --- | --- |
| message | <code>object</code> | base object that the outgoing Message should be based on |
### createOutgoingMessageFor
<a name="BaseBot.createOutgoingMessageFor"></a>
### BaseBot.createOutgoingMessageFor(recipientId) ⇒ <code>OutgoingMessage</code>
same as #createOutgoingMessage, creates empty outgoingMessage with

@@ -397,165 +395,10 @@ id of the recipient set. Again, this is jut sugar syntax for creating a

**Parameters**
This is the static version of this method
- `recipientId` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** id of the recipient the message is for
**Kind**: static method of <code>[BaseBot](#BaseBot)</code>
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. A valid OutgoingMessage object with recipient set.
Returns **[OutgoingMessage](#outgoingmessage)** outgoingMessage. A valid OutgoingMessage object with recipient set.
| Param | Type | Description |
| --- | --- | --- |
| recipientId | <code>string</code> | id of the recipient the message is for |
## OutgoingMessage
This class will help you compose sendable message objects.
### addRecipientById
Adds recipient.id param to the OutgoingMessage object. This is most
likely what you will want to do to add a recipient. Alternatively, you Can
use addRecipientByPhoneNumber if the platform you are sending the message to
supports that.
**Parameters**
- `id` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the id to add to the OutgoingMessage object
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addRecipientByPhoneNumber
Adds recipient.phone_number param to the OutgoingMessage object.
You might prefer to add a recipient by id rather. This is achieved via
addRecipientById
**Parameters**
- `phoneNumber` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the phone number to add to the OutgoingMessage object
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### removeRecipient
removes the recipient param from the OutgoingMessage object.
This will remove the object wether it was set with a phone number or an id
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addText
Adds message.text to the OutgoingMessage
**Parameters**
- `text` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the text to add to the OutgoingMessage object
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### removeText
Removes the message.text param from the OutgoingMessage object.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addAttachment
Adds message.attachment to the OutgoingMessage. If you want to add
an attachment simply from a type and a url, have a look at:
addAttachmentFromUrl
**Parameters**
- `attachment` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** valid messenger type attachment that can be
formatted by the platforms your bot uses
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addAttachmentFromUrl
Adds message.attachment from a type and url without requiring you to
provide the whole attachment object. If you want to add an attachment using
a full object, use addAttachment.
**Parameters**
- `type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the attachment type (audio, video, image, file)
- `url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the url of the attachment.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### removeAttachment
Removes message.attachment param from the OutgoingMessage object.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addQuickReplies
Adds message.quick_replies to the OutgoinMessage object. Use
addPayloadLessQuickReplies if you just want to add quick replies from an
array of titles
**Parameters**
- `quickReplies` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The quick replies objects to add to the
OutgoingMessage
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addPayloadLessQuickReplies
Adds message.quick_replies to the OutgoinMessage object from a simple array
of quick replies titles.Use addQuickReplies if want to add quick replies
from an quick reply objects
**Parameters**
- `quickRepliesTitles` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The titles of the quick replies objects to add to the
OutgoingMessage
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addLocationQuickReply
Adds a content_type: location message.quick_replies to the OutgoingMessage.
Use this if the platform the bot class you are using is based on supports
asking for the location to its users.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### removeQuickReplies
Removes message.quick_replies param from the OutgoingMessage object.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addSenderAction
Adds an arbitrary sender_action to the OutgoinMessage
**Parameters**
- `senderAction` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Arbitrary sender action
(typing_on, typing_off or mark_seens)
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addTypingOnSenderAction
Adds "typing_on" sender_action to the OutgoinMessage
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addTypingOffSenderAction
Adds "typing_off" sender_action to the OutgoinMessage
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addMarkSeenSenderAction
Adds "mark_seen" sender_action to the OutgoinMessage
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### removeSenderAction
Removes sender_action param from the OutgoingMessage object.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.

@@ -1,89 +0,119 @@

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
<a name="Botmaster"></a>
### Table of Contents
- [Botmaster](#botmaster)
- [constructor](#constructor)
- [addBot](#addbot)
- [getBot](#getbot)
- [getBots](#getbots)
- [removeBot](#removebot)
- [use](#use)
- [useWrapped](#usewrapped)
## Botmaster
The Botmaster class to rule them all
**Extends EventEmitter**
**Kind**: global class
The Botmaster class to rule them all
* [Botmaster](#Botmaster)
* [new Botmaster(settings)](#new_Botmaster_new)
* [.addBot(bot)](#Botmaster+addBot) ⇒ <code>[Botmaster](#Botmaster)</code>
* [.getBot(options)](#Botmaster+getBot) ⇒ <code>BaseBot</code>
* [.getBots(botType)](#Botmaster+getBots) ⇒ <code>Array</code>
* [.removeBot(bot)](#Botmaster+removeBot) ⇒ <code>[Botmaster](#Botmaster)</code>
* [.use(middleware)](#Botmaster+use) ⇒ <code>[Botmaster](#Botmaster)</code>
* [.useWrapped(incomingMiddleware, outgoingMiddleware)](#Botmaster+useWrapped) ⇒ <code>[Botmaster](#Botmaster)</code>
### constructor
<a name="new_Botmaster_new"></a>
### new Botmaster(settings)
sets up a botmaster object attached to the correct server if one is set
as a parameter. If not, it creates its own http server
**Parameters**
- `settings` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
| Param | Type |
| --- | --- |
| settings | <code>object</code> |
### addBot
**Example**
```js
// attach the botmaster generated server to port 5000 rather than the default 3000
const botmaster = new Botmaster({
port: 5000,
});
```
**Example**
```js
const http = require('http');
const myServer = http.createServer()
// use my own server rather than letting botmaster creat its own.
const botmaster = new Botmaster({
server: myServer,
});
```
<a name="Botmaster+addBot"></a>
### botmaster.addBot(bot) ⇒ <code>[Botmaster](#Botmaster)</code>
Add an existing bot to this instance of Botmaster
**Parameters**
**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object for chaining
- `bot` **BaseBot** the bot object to add to botmaster. Must be from
a subclass of BaseBot
| Param | Type | Description |
| --- | --- | --- |
| bot | <code>BaseBot</code> | the bot object to add to botmaster. Must be from a subclass of BaseBot |
Returns **[Botmaster](#botmaster)** returns the botmaster object for chaining
<a name="Botmaster+getBot"></a>
### getBot
### botmaster.getBot(options) ⇒ <code>BaseBot</code>
Extract First bot of given type or provided id.
**Parameters**
**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>BaseBot</code> - The bot found of a class that inherits of BaseBot
- `options` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** must be { type: 'someBotType} or { id: someBotId }.
| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | must be { type: 'someBotType} or { id: someBotId }. |
Returns **BaseBot** The bot found of a class that inherits of BaseBot
<a name="Botmaster+getBots"></a>
### getBots
### botmaster.getBots(botType) ⇒ <code>Array</code>
Extract all bots of given type.
**Parameters**
**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>Array</code> - Array of bots found
- `botType` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** (there can be multiple bots of a same type)
| Param | Type | Description |
| --- | --- | --- |
| botType | <code>string</code> | (there can be multiple bots of a same type) |
Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of bots found
<a name="Botmaster+removeBot"></a>
### removeBot
### botmaster.removeBot(bot) ⇒ <code>[Botmaster](#Botmaster)</code>
Remove an existing bot from this instance of Botmaster
**Parameters**
**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object for chaining
- `bot` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
| Param | Type |
| --- | --- |
| bot | <code>Object</code> |
Returns **[Botmaster](#botmaster)** returns the botmaster object for chaining
<a name="Botmaster+use"></a>
### use
### botmaster.use(middleware) ⇒ <code>[Botmaster](#Botmaster)</code>
Add middleware to this botmaster object
This function is just sugar for `middleware.__use` in them
**Parameters**
**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object so you can chain middleware
- `middleware` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
| Param | Type |
| --- | --- |
| middleware | <code>object</code> |
**Examples**
```javascript
**Example**
```js
// The middleware param object is something that looks like this for incoming:
{
type: 'incoming',
name: 'my-incoming-middleware',
controller: (bot, update, next) => {
// do stuff with update,
// call next (or return a promise)
}
},
// includeEcho: true (defaults to false), opt-in to get echo updates
// includeDelivery: true (defaults to false), opt-in to get delivery updates
// includeRead: true (defaults to false), opt-in to get user read updates
}

@@ -95,2 +125,3 @@

type: 'outgoing',
name: 'my-outgoing-middleware',
controller: (bot, update, message, next) => {

@@ -102,7 +133,5 @@ // do stuff with message,

```
<a name="Botmaster+useWrapped"></a>
Returns **[Botmaster](#botmaster)** returns the botmaster object so you can chain middleware
### useWrapped
### botmaster.useWrapped(incomingMiddleware, outgoingMiddleware) ⇒ <code>[Botmaster](#Botmaster)</code>
Add wrapped middleware to this botmaster instance. Wrapped middleware

@@ -113,7 +142,9 @@ places the incoming middleware at beginning of incoming stack and

**Parameters**
**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object so you can chain middleware
- `incomingMiddleware` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `outgoingMiddleware` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** The middleware objects are as you'd expect them to be (see use)
| Param | Type | Description |
| --- | --- | --- |
| incomingMiddleware | <code>object</code> | |
| outgoingMiddleware | <code>object</code> | The middleware objects are as you'd expect them to be (see use) |
Returns **[Botmaster](#botmaster)** returns the botmaster object so you can chain middleware

@@ -1,31 +0,48 @@

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
<a name="OutgoingMessage"></a>
### Table of Contents
## OutgoingMessage
This class will help you compose sendable message objects.
- [OutgoingMessage](#outgoingmessage)
- [addRecipientById](#addrecipientbyid)
- [addRecipientByPhoneNumber](#addrecipientbyphonenumber)
- [removeRecipient](#removerecipient)
- [addText](#addtext)
- [removeText](#removetext)
- [addAttachment](#addattachment)
- [addAttachmentFromUrl](#addattachmentfromurl)
- [removeAttachment](#removeattachment)
- [addQuickReplies](#addquickreplies)
- [addPayloadLessQuickReplies](#addpayloadlessquickreplies)
- [addLocationQuickReply](#addlocationquickreply)
- [removeQuickReplies](#removequickreplies)
- [addSenderAction](#addsenderaction)
- [addTypingOnSenderAction](#addtypingonsenderaction)
- [addTypingOffSenderAction](#addtypingoffsenderaction)
- [addMarkSeenSenderAction](#addmarkseensenderaction)
- [removeSenderAction](#removesenderaction)
**Kind**: global class
## OutgoingMessage
* [OutgoingMessage](#OutgoingMessage)
* [new OutgoingMessage([message])](#new_OutgoingMessage_new)
* [.addRecipientById(id)](#OutgoingMessage+addRecipientById) ⇒ <code>OutgoinMessage</code>
* [.addRecipientByPhoneNumber(phoneNumber)](#OutgoingMessage+addRecipientByPhoneNumber) ⇒ <code>OutgoinMessage</code>
* [.removeRecipient()](#OutgoingMessage+removeRecipient) ⇒ <code>OutgoinMessage</code>
* [.addText(text)](#OutgoingMessage+addText) ⇒ <code>OutgoinMessage</code>
* [.removeText()](#OutgoingMessage+removeText) ⇒ <code>OutgoinMessage</code>
* [.addAttachment(attachment)](#OutgoingMessage+addAttachment) ⇒ <code>OutgoinMessage</code>
* [.addAttachmentFromUrl(type, url)](#OutgoingMessage+addAttachmentFromUrl) ⇒ <code>OutgoinMessage</code>
* [.removeAttachment()](#OutgoingMessage+removeAttachment) ⇒ <code>OutgoinMessage</code>
* [.addQuickReplies(quickReplies)](#OutgoingMessage+addQuickReplies) ⇒ <code>OutgoinMessage</code>
* [.addPayloadLessQuickReplies(quickRepliesTitles)](#OutgoingMessage+addPayloadLessQuickReplies) ⇒ <code>OutgoinMessage</code>
* [.addLocationQuickReply()](#OutgoingMessage+addLocationQuickReply) ⇒ <code>OutgoinMessage</code>
* [.removeQuickReplies()](#OutgoingMessage+removeQuickReplies) ⇒ <code>OutgoinMessage</code>
* [.addSenderAction(senderAction)](#OutgoingMessage+addSenderAction) ⇒ <code>OutgoinMessage</code>
* [.addTypingOnSenderAction()](#OutgoingMessage+addTypingOnSenderAction) ⇒ <code>OutgoinMessage</code>
* [.addTypingOffSenderAction()](#OutgoingMessage+addTypingOffSenderAction) ⇒ <code>OutgoinMessage</code>
* [.addMarkSeenSenderAction()](#OutgoingMessage+addMarkSeenSenderAction) ⇒ <code>OutgoinMessage</code>
* [.removeSenderAction()](#OutgoingMessage+removeSenderAction) ⇒ <code>OutgoinMessage</code>
This class will help you compose sendable message objects.
<a name="new_OutgoingMessage_new"></a>
### addRecipientById
### new OutgoingMessage([message])
Constructor to the OutgoingMessage class. Takes in an optional
message object that it will use as its base to add the OutgoingMessage
methods to. This constructor is not actually exposed in the public API.
In order to instantiate an OutgoingMessage object, you'll need to use the
createOutgoingMessage and createOutgoingMessageFor methods provided with
all classes that inherit from BaseBot. There are static and non-static
versions of both methods to make sure you can do so wherever as you wish
Adds recipient.id param to the OutgoingMessage object. This is most
| Param | Type | Description |
| --- | --- | --- |
| [message] | <code>object</code> | the base object to convert into an OutgoingMessage object |
<a name="OutgoingMessage+addRecipientById"></a>
### outgoingMessage.addRecipientById(id) ⇒ <code>OutgoinMessage</code>
Adds `recipient.id` param to the OutgoingMessage object. This is most
likely what you will want to do to add a recipient. Alternatively, you Can

@@ -35,148 +52,169 @@ use addRecipientByPhoneNumber if the platform you are sending the message to

**Parameters**
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
- `id` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the id to add to the OutgoingMessage object
| Param | Type | Description |
| --- | --- | --- |
| id | <code>string</code> | the id to add to the OutgoingMessage object |
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addRecipientByPhoneNumber"></a>
### addRecipientByPhoneNumber
Adds recipient.phone_number param to the OutgoingMessage object.
### outgoingMessage.addRecipientByPhoneNumber(phoneNumber) ⇒ <code>OutgoinMessage</code>
Adds `recipient.phone_number` param to the OutgoingMessage object.
You might prefer to add a recipient by id rather. This is achieved via
addRecipientById
**Parameters**
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
- `phoneNumber` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the phone number to add to the OutgoingMessage object
| Param | Type | Description |
| --- | --- | --- |
| phoneNumber | <code>string</code> | the phone number to add to the OutgoingMessage object |
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
<a name="OutgoingMessage+removeRecipient"></a>
### removeRecipient
removes the recipient param from the OutgoingMessage object.
### outgoingMessage.removeRecipient() ⇒ <code>OutgoinMessage</code>
removes the `recipient` param from the OutgoingMessage object.
This will remove the object wether it was set with a phone number or an id
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addText"></a>
### addText
### outgoingMessage.addText(text) ⇒ <code>OutgoinMessage</code>
Adds `message.text` to the OutgoingMessage
Adds message.text to the OutgoingMessage
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
**Parameters**
| Param | Type | Description |
| --- | --- | --- |
| text | <code>string</code> | the text to add to the OutgoingMessage object |
- `text` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the text to add to the OutgoingMessage object
<a name="OutgoingMessage+removeText"></a>
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### outgoingMessage.removeText() ⇒ <code>OutgoinMessage</code>
Removes the `message.text` param from the OutgoingMessage object.
### removeText
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addAttachment"></a>
Removes the message.text param from the OutgoingMessage object.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addAttachment
Adds message.attachment to the OutgoingMessage. If you want to add
### outgoingMessage.addAttachment(attachment) ⇒ <code>OutgoinMessage</code>
Adds `message.attachment` to the OutgoingMessage. If you want to add
an attachment simply from a type and a url, have a look at:
addAttachmentFromUrl
**Parameters**
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
- `attachment` **[object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** valid messenger type attachment that can be
formatted by the platforms your bot uses
| Param | Type | Description |
| --- | --- | --- |
| attachment | <code>object</code> | valid messenger type attachment that can be formatted by the platforms your bot uses |
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addAttachmentFromUrl"></a>
### addAttachmentFromUrl
Adds message.attachment from a type and url without requiring you to
### outgoingMessage.addAttachmentFromUrl(type, url) ⇒ <code>OutgoinMessage</code>
Adds `message.attachment` from a type and url without requiring you to
provide the whole attachment object. If you want to add an attachment using
a full object, use addAttachment.
**Parameters**
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
- `type` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the attachment type (audio, video, image, file)
- `url` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** the url of the attachment.
| Param | Type | Description |
| --- | --- | --- |
| type | <code>string</code> | the attachment type (audio, video, image, file) |
| url | <code>string</code> | the url of the attachment. |
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
<a name="OutgoingMessage+removeAttachment"></a>
### removeAttachment
### outgoingMessage.removeAttachment() ⇒ <code>OutgoinMessage</code>
Removes `message.attachment` param from the OutgoingMessage object.
Removes message.attachment param from the OutgoingMessage object.
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addQuickReplies"></a>
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addQuickReplies
Adds message.quick_replies to the OutgoinMessage object. Use
### outgoingMessage.addQuickReplies(quickReplies) ⇒ <code>OutgoinMessage</code>
Adds `message.quick_replies` to the OutgoinMessage object. Use
addPayloadLessQuickReplies if you just want to add quick replies from an
array of titles
**Parameters**
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
- `quickReplies` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The quick replies objects to add to the
OutgoingMessage
| Param | Type | Description |
| --- | --- | --- |
| quickReplies | <code>Array</code> | The quick replies objects to add to the OutgoingMessage |
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addPayloadLessQuickReplies"></a>
### addPayloadLessQuickReplies
Adds message.quick_replies to the OutgoinMessage object from a simple array
### outgoingMessage.addPayloadLessQuickReplies(quickRepliesTitles) ⇒ <code>OutgoinMessage</code>
Adds `message.quick_replies` to the OutgoinMessage object from a simple array
of quick replies titles.Use addQuickReplies if want to add quick replies
from an quick reply objects
**Parameters**
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
- `quickRepliesTitles` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** The titles of the quick replies objects to add to the
OutgoingMessage
| Param | Type | Description |
| --- | --- | --- |
| quickRepliesTitles | <code>Array</code> | The titles of the quick replies objects to add to the OutgoingMessage |
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addLocationQuickReply"></a>
### addLocationQuickReply
Adds a content_type: location message.quick_replies to the OutgoingMessage.
### outgoingMessage.addLocationQuickReply() ⇒ <code>OutgoinMessage</code>
Adds a `content_type: location` message.quick_replies to the OutgoingMessage.
Use this if the platform the bot class you are using is based on supports
asking for the location to its users.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+removeQuickReplies"></a>
### removeQuickReplies
### outgoingMessage.removeQuickReplies() ⇒ <code>OutgoinMessage</code>
Removes `message.quick_replies` param from the OutgoingMessage object.
Removes message.quick_replies param from the OutgoingMessage object.
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addSenderAction"></a>
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### outgoingMessage.addSenderAction(senderAction) ⇒ <code>OutgoinMessage</code>
Adds an arbitrary `sender_action` to the OutgoinMessage
### addSenderAction
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
Adds an arbitrary sender_action to the OutgoinMessage
| Param | Type | Description |
| --- | --- | --- |
| senderAction | <code>string</code> | Arbitrary sender action (typing_on, typing_off or mark_seens) |
**Parameters**
<a name="OutgoingMessage+addTypingOnSenderAction"></a>
- `senderAction` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Arbitrary sender action
(typing_on, typing_off or mark_seens)
### outgoingMessage.addTypingOnSenderAction() ⇒ <code>OutgoinMessage</code>
Adds `sender_action: typing_on` to the OutgoinMessage
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addTypingOffSenderAction"></a>
### addTypingOnSenderAction
### outgoingMessage.addTypingOffSenderAction() ⇒ <code>OutgoinMessage</code>
Adds `sender_action: typing_off` to the OutgoinMessage
Adds "typing_on" sender_action to the OutgoinMessage
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+addMarkSeenSenderAction"></a>
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### outgoingMessage.addMarkSeenSenderAction() ⇒ <code>OutgoinMessage</code>
Adds `sender_action: mark_seen` to the OutgoinMessage
### addTypingOffSenderAction
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.
<a name="OutgoingMessage+removeSenderAction"></a>
Adds "typing_off" sender_action to the OutgoinMessage
### outgoingMessage.removeSenderAction() ⇒ <code>OutgoinMessage</code>
Removes `sender_action` param from the OutgoingMessage object.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### addMarkSeenSenderAction
Adds "mark_seen" sender_action to the OutgoinMessage
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
### removeSenderAction
Removes sender_action param from the OutgoingMessage object.
Returns **OutgoinMessage** returns this object to allow for chaining of methods.
**Kind**: instance method of <code>[OutgoingMessage](#OutgoingMessage)</code>
**Returns**: <code>OutgoinMessage</code> - returns this object to allow for chaining of methods.

@@ -143,3 +143,3 @@ 'use strict';

/**
* #createOutgoingMessage exposes the OutgoingMessage constructor
* createOutgoingMessage exposes the OutgoingMessage constructor
* via BaseBot. This simply means one can create their own

@@ -149,2 +149,4 @@ * OutgoingMessage object using any bot object. They can then compose

*
* This is the static version of this method
*
* @param {object} message base object that the outgoing Message should be based on

@@ -159,2 +161,15 @@ *

/**
* createOutgoingMessage exposes the OutgoingMessage constructor
* via BaseBot. This simply means one can create their own
* OutgoingMessage object using any bot object. They can then compose
* it with all its helper functions
*
* This is the instance version of this method
*
* @param {object} message base object that the outgoing Message should be based on
*
* @return {OutgoingMessage} outgoingMessage. The same object passed in with
* all the helper functions from OutgoingMessage
*/
createOutgoingMessage(message) {

@@ -169,2 +184,4 @@ return BaseBot.createOutgoingMessage(message);

*
* This is the static version of this method
*
* @param {string} recipientId id of the recipient the message is for

@@ -179,2 +196,14 @@ *

/**
* same as #createOutgoingMessage, creates empty outgoingMessage with
* id of the recipient set. Again, this is jut sugar syntax for creating a
* new outgoingMessage object
*
* This is the instance version of this method
*
* @param {string} recipientId id of the recipient the message is for
*
* @return {OutgoingMessage} outgoingMessage. A valid OutgoingMessage object with recipient set.
*/
createOutgoingMessageFor(recipientId) {

@@ -189,19 +218,26 @@ return BaseBot.createOutgoingMessageFor(recipientId);

* @param {object} message
* @param {boolean} [sendOptions] options used for sending the message. e.g. ignoreMiddleware
* @param {boolean} [sendOptions] an object containing options regarding the
* sending of the message. Currently the only valid options is: `ignoreMiddleware`.
*
* @return {Promise}
* @return {Promise} promise that resolves with a body object (see example)
*
* @example
* const outgoingMessage = bot.createOutgoingMessageFor(update.sender.id);
* outgoingMessage.addText('Hello world');
*
* bot.sendMessage(outgoingMessage);
*
* @example
* // The returned promise for all sendMessage type events resolves with
* // a body that looks something like this:
* {
* raw: rawBody, // can be undefined (e.g. if rawBody is directly returned)
* sentOutgoingMessage: // the OutgoingMessage instance before being formatted
* sentRawMessage: // the OutgoingMessage object after being formatted for the platforms
* raw: rawBody, // the raw response from the platforms received from sending the message
* recipient_id: <id_of_user>,
* message_id: <message_id_of_what_was_just_sent>
* sentMessage: <sent_message_object>
* }
*
* // Some platforms may not have either of these parameters. If that's the case,
* // the value assigned will be null or some other suitable value as the
* // equivalent to Messenger's seq in Telegram.
* // the value assigned will be a falsy value
*

@@ -223,3 +259,3 @@ */

outgoingMiddlewarePromise = this.master.middleware.__runOutgoingMiddleware(
this, sendOptions.__update, outgoingMessage);
this, this.__associatedUpdate, outgoingMessage);
} else {

@@ -306,14 +342,19 @@ // don't actually go through middleware

* #sendMessage if you want to send instances of OutgoingMessage
* @param {string} recipientId
* @param {object} [sendOptions] just options for sending.
* @param {string} recipientId a string representing the id of the user to
* whom you want to send the message.
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
*
* @return {Promise} promise that resolves with a body object
* (see `sendMessage` example)
*
* @example
*
* // message object can look something like this:
*
* message: {
* // as you can see, this is not an OutgoingMessage instance
* const message = {
* text: 'Some random text'
* }
*
* @return {Promise} promise
* bot.sendMessageTo(message, update.sender.id);
*
*/

@@ -333,6 +374,11 @@ sendMessageTo(message, recipientId, sendOptions) {

* @param {string} text
* @param {string} recipientId
* @param {object} [sendOptions] just options for sending.
* @param {string} recipientId a string representing the id of the user to
* whom you want to send the message.
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
*
* @return {Promise} promise
* @return {Promise} promise that resolves with a body object
* (see `sendMessage` example)
*
* @example
* bot.sendTextMessageTo('something super important', update.sender.id);
*/

@@ -355,6 +401,9 @@ sendTextMessageTo(text, recipientId, sendOptions) {

* @param {object} incomingUpdate
* @param {string} text
* @param {object} [sendOptions] just options for sending.
* @param {string} text text to send to the user associated with the received update
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
* @return {Promise} promise that resolves with a body object
* (see `sendMessage` example)
*
* @return {Promise} promise
* @example
* bot.reply(update, 'something super important!');
*/

@@ -368,6 +417,14 @@ reply(incomingUpdate, text, sendOptions) {

* less structure.
* @param {object} attachment
* @param {object} attachment a valid Messenger style attachment.
* See [here](https://developers.facebook.com/docs/messenger-platform/send-api-reference)
* for more on that.
*
* @param {string} recipientId a string representing the id of the user to
* whom you want to send the message.
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
*
* @return {Promise} promise that resolves with a body object
* (see `sendMessage` example)
* @example
* // attachment object typically looks something like this:
*
* const attachment = {

@@ -380,6 +437,3 @@ * type: 'image',

*
* @param {string} recipientId
* @param {object} [sendOptions] just options for sending.
*
* @return {Promise} promise
* bot.sendAttachmentTo(attachment, update.sender.id);
*/

@@ -400,8 +454,14 @@ sendAttachmentTo(attachment, recipientId, sendOptions) {

* minimal structure.
* @param {string} type
* @param {string} url
* @param {string} recipientId
* @param {object} [sendOptions] just options for sending.
* @param {string} type string representing the type of attachment
* (audio, video, image or file)
* @param {string} url the url to your file
* @param {string} recipientId a string representing the id of the user to
* whom you want to send the message.
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
*
* @return {Promise} promise
* @return {Promise} promise that resolves with a body object
* (see `sendMessage` example)
*
* @example
* bot.sendAttachmentFromURLTo('image', "some image url you've got", update.sender.id);
*/

@@ -432,9 +492,20 @@ sendAttachmentFromUrlTo(type, url, recipientId, sendOptions) {

*
* @param {Array} buttonTitles
* @param {string|object} textOrAttachment, if falsy, will be set to a
* default text of "Please select one of:"
* @param {string} recipientId
* @param {object} [sendOptions]
* @param {Array} buttonTitles array of button titles (no longer than 10 in size).
* @param {string_OR_object} textOrAttachment a string or an attachment object
* similar to the ones required in `bot.sendAttachmentTo`.
* This is meant to provide context to the buttons.
* I.e. why are there buttons here. A piece of text or an attachment
* could detail that. If falsy, text will be added that reads:
* 'Please select one of:'.
* @param {string} recipientId a string representing the id of the user to
* whom you want to send the message.
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
*
* @return {Promise} promise
* @return {Promise} promise that resolves with a body object
* (see `sendMessage` example)
*
* @example
* const buttonArray = ['button1', 'button2'];
* bot.sendDefaultButtonMessageTo(buttonArray,
* 'Please select "button1" or "button2"', update.sender.id,);
*/

@@ -508,22 +579,13 @@ sendDefaultButtonMessageTo(buttonTitles, textOrAttachment, recipientId) {

* if available.
* based on the passed in update
*
* @param {string} recipientId a string representing the id of the user to
* whom you want to send the message.
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
*
* i.e. it has no message_id (or it is null/undefined)
* @return {Promise} promise that resolves with a body object
* (see `sendMessage` example)
*
* @param {string} recipientId
* @param {object} [sendOptions]
*
* @return {Promise} promise
*
* @example
*
* // the returned value is different from the standard one. It looks something
* //like this in this case:
*
* {
* recipient_id: <id_of_user>
* }
*
*
* bot.sendIsTypingMessageTo(update.sender.id);
* // the returned value is different from the standard one. it won't have a message_id
*/

@@ -545,3 +607,3 @@ sendIsTypingMessageTo(recipientId, sendOptions) {

/**
* sendCascadeTo() allows developers to send a cascade of messages
* sendCascade() allows developers to send a cascade of messages
* in a sequence. All types of messages can be sent (including raw messages).

@@ -551,9 +613,23 @@ *

* [{raw: someRawObject}, {message: some valid outgoingMessage}]
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`. will
* only apply to non rawMessages. (remember that for rawMessages, outgoing
* middleware is bypassed anyways).
*
* @return {Promise} promise
* The returned value an in-place array of bodies received from the client platform
* The objects of the array are of the same format as for standard messages
* @return {Promise} promise that resolves with an array of body objects
* (see `sendMessage` example for one said object)
*
* @example
* const rawMessage1 = {
* nonStandard: 'message1',
* recipient: {
* id: 'user_id',
* },
* };
* const message2 = bot.createOutgoingMessageFor(update.sender.id);
* message2.addText('some text');
*
* const messageArray = [{ raw: rawMessage1 }, { message: message2 }];
*
* bot.sendCascade(messageArray);
*/
sendCascade(messageArray, sendOptions) {

@@ -591,9 +667,12 @@ const returnedBodies = [];

*
* @param {Array} textArray of messages in a format as such: ['message1', 'message2']
* @param {string} recipientId just the id of the recipient to send the messages to.
* @param {Array} textArray of messages.
* @param {string} recipientId a string representing the id of the user to
* whom you want to send the message.
* @param {object} [sendOptions] see `sendOptions` for `sendMessage`
*
* @return {Promise} promise
* The returned value an in-place array of bodies received from the client platform
* The objects of the array are of the same format as for standard messages
* @return {Promise} promise that resolves with an array of body objects
* (see `sendMessage` example for one said object)
*
* @example
* bot.sendTextCascadeTo(['message1', 'message2'], user.sender.id);
*/

@@ -695,3 +774,3 @@

*/
getUserInfo(userId) {
getUserInfo(userId, options) {
if (!this.retrievesUserInfo) {

@@ -701,3 +780,3 @@ return Promise.reject(TypeError(

}
return this.__getUserInfo(userId);
return this.__getUserInfo(userId, options);
}

@@ -717,14 +796,3 @@

const newBot = Object.create(this);
newBot.sendMessage = (message, sendOptions) => {
sendOptions = sendOptions || {};
// validating here too, as __update has to be added to a valid
// sendOptions object
return this.__validateSendOptions(sendOptions)
.then(() => {
sendOptions.__update = update;
return this.sendMessage(message, sendOptions);
});
};
newBot.__associatedUpdate = update;
return newBot;

@@ -731,0 +799,0 @@ }

@@ -7,2 +7,3 @@ 'use strict';

const remove = require('lodash').remove;
const has = require('lodash').has;
const debug = require('debug')('botmaster:botmaster');

@@ -22,2 +23,17 @@ const TwoDotXError = require('./errors').TwoDotXError;

* @param {object} settings
*
* @example
* // attach the botmaster generated server to port 5000 rather than the default 3000
* const botmaster = new Botmaster({
* port: 5000,
* });
*
* @example
* const http = require('http');
*
* const myServer = http.createServer()
* // use my own server rather than letting botmaster creat its own.
* const botmaster = new Botmaster({
* server: myServer,
* });
*/

@@ -27,3 +43,3 @@

super();
this.settings = settings;
this.settings = settings || {};
this.__throwPotentialUnsupportedSettingsErrors();

@@ -35,2 +51,6 @@ this.__setupServer();

this.__serverRequestListeners = {};
// default useDefaultMountPathPrepend to true
if (this.settings.useDefaultMountPathPrepend === undefined) {
this.settings.useDefaultMountPathPrepend = true;
}
this.bots = [];

@@ -43,3 +63,3 @@ }

for (const settingName of unsupportedSettings) {
if (this.settings && this.settings[settingName]) {
if (this.settings[settingName]) {
throw new TwoDotXError(

@@ -53,15 +73,11 @@ `Starting botmaster with ${settingName} ` +

__setupServer() {
if (this.settings && this.settings.server && this.settings.port) {
if (this.settings.server && this.settings.port) {
throw new Error(
'IncompatibleArgumentsError: Please specify only ' +
'one of port and server');
} else if (this.settings && !this.settings.server && !this.settings.port) {
throw new Error(
'If passing through settings, please specify exactly one of port or server' +
'If you want botmaster to use its defaults, just use the constructor with no params');
}
if (this.settings && this.settings.server) {
if (this.settings.server) {
this.server = this.settings.server;
} else {
const port = this.settings
const port = has(this, 'settings.port')
? this.settings.port

@@ -121,3 +137,9 @@ : 3000;

if (bot.requiresWebhook) {
const path = `/${bot.type}/${bot.webhookEndpoint}`;
const webhookEndpoint = bot.webhookEndpoint.replace(/^\/|\/$/g, '');
const path = this.settings.useDefaultMountPathPrepend
? `/${bot.type}/${webhookEndpoint}`
: `/${webhookEndpoint}`;
console.log(path)
this.__serverRequestListeners[path] = bot.requestListener;

@@ -211,6 +233,10 @@ }

* type: 'incoming',
* name: 'my-incoming-middleware',
* controller: (bot, update, next) => {
* // do stuff with update,
* // call next (or return a promise)
* }
* },
* // includeEcho: true (defaults to false), opt-in to get echo updates
* // includeDelivery: true (defaults to false), opt-in to get delivery updates
* // includeRead: true (defaults to false), opt-in to get user read updates
* }

@@ -222,2 +248,3 @@ *

* type: 'outgoing',
* name: 'my-outgoing-middleware',
* controller: (bot, update, message, next) => {

@@ -224,0 +251,0 @@ * // do stuff with message,

@@ -59,3 +59,3 @@ 'use strict';

/**
* Adds recipient.id param to the OutgoingMessage object. This is most
* Adds `recipient.id` param to the OutgoingMessage object. This is most
* likely what you will want to do to add a recipient. Alternatively, you Can

@@ -76,3 +76,3 @@ * use addRecipientByPhoneNumber if the platform you are sending the message to

/**
* Adds recipient.phone_number param to the OutgoingMessage object.
* Adds `recipient.phone_number` param to the OutgoingMessage object.
* You might prefer to add a recipient by id rather. This is achieved via

@@ -92,3 +92,3 @@ * addRecipientById

/**
* removes the recipient param from the OutgoingMessage object.
* removes the `recipient` param from the OutgoingMessage object.
* This will remove the object wether it was set with a phone number or an id

@@ -103,3 +103,3 @@ *

/**
* Adds message.text to the OutgoingMessage
* Adds `message.text` to the OutgoingMessage
*

@@ -114,3 +114,3 @@ * @param {string} text the text to add to the OutgoingMessage object

/**
* Removes the message.text param from the OutgoingMessage object.
* Removes the `message.text` param from the OutgoingMessage object.
*

@@ -124,3 +124,3 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

/**
* Adds message.attachment to the OutgoingMessage. If you want to add
* Adds `message.attachment` to the OutgoingMessage. If you want to add
* an attachment simply from a type and a url, have a look at:

@@ -138,3 +138,3 @@ * addAttachmentFromUrl

/**
* Adds message.attachment from a type and url without requiring you to
* Adds `message.attachment` from a type and url without requiring you to
* provide the whole attachment object. If you want to add an attachment using

@@ -165,3 +165,3 @@ * a full object, use addAttachment.

/**
* Removes message.attachment param from the OutgoingMessage object.
* Removes `message.attachment` param from the OutgoingMessage object.
*

@@ -175,3 +175,3 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

/**
* Adds message.quick_replies to the OutgoinMessage object. Use
* Adds `message.quick_replies` to the OutgoinMessage object. Use
* addPayloadLessQuickReplies if you just want to add quick replies from an

@@ -189,3 +189,3 @@ * array of titles

/**
* Adds message.quick_replies to the OutgoinMessage object from a simple array
* Adds `message.quick_replies` to the OutgoinMessage object from a simple array
* of quick replies titles.Use addQuickReplies if want to add quick replies

@@ -220,5 +220,5 @@ * from an quick reply objects

/**
* Adds a content_type: location message.quick_replies to the OutgoingMessage.
* Adds a `content_type: location` message.quick_replies to the OutgoingMessage.
* Use this if the platform the bot class you are using is based on supports
* asking for the location to its users.
* asking for the location to its users.
*

@@ -238,3 +238,3 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

/**
* Removes message.quick_replies param from the OutgoingMessage object.
* Removes `message.quick_replies` param from the OutgoingMessage object.
*

@@ -248,3 +248,3 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

/**
* Adds an arbitrary sender_action to the OutgoinMessage
* Adds an arbitrary `sender_action` to the OutgoinMessage
* @param {string} senderAction Arbitrary sender action

@@ -259,3 +259,3 @@ * (typing_on, typing_off or mark_seens)

/**
* Adds "typing_on" sender_action to the OutgoinMessage
* Adds `sender_action: typing_on` to the OutgoinMessage
*

@@ -269,3 +269,3 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

/**
* Adds "typing_off" sender_action to the OutgoinMessage
* Adds `sender_action: typing_off` to the OutgoinMessage
*

@@ -279,3 +279,3 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

/**
* Adds "mark_seen" sender_action to the OutgoinMessage
* Adds `sender_action: mark_seen` to the OutgoinMessage
*

@@ -289,3 +289,3 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

/**
* Removes sender_action param from the OutgoingMessage object.
* Removes `sender_action` param from the OutgoingMessage object.
*

@@ -292,0 +292,0 @@ * @return {OutgoinMessage} returns this object to allow for chaining of methods.

{
"name": "botmaster",
"version": "3.0.8",
"version": "3.1.0",
"description": "Framework allowing developers to write bots that are agnostic with respect to the channel used by their users (messenger, telegram etc...)",

@@ -9,8 +9,9 @@ "main": "./lib/index.js",

"test-debug": "export NODE_ENV=test DEBUG=botmaster:*; nyc --reporter=lcov --reporter=html ava",
"test-watch": "export NODE_ENV=test; ava --watch",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"postversion": "git push && git push --tags && rm -rf build/temp",
"postversion": "git push && git push --tags",
"report": "nyc report",
"botmaster-docs": "documentation build lib/botmaster.js -f md > api-reference/botmaster.md",
"base-bot-docs": "documentation build lib/base_bot.js -f md > api-reference/base-bot.md",
"outgoing-message-docs": "documentation build lib/outgoing_message.js -f md > api-reference/outgoing-message.md",
"botmaster-docs": "jsdoc2md lib/botmaster.js > api-reference/botmaster.md",
"base-bot-docs": "jsdoc2md lib/base_bot.js > api-reference/base-bot.md",
"outgoing-message-docs": "jsdoc2md lib/outgoing_message.js > api-reference/outgoing-message.md",
"docs": "mkdir -p api-reference; yarn botmaster-docs; yarn base-bot-docs; yarn outgoing-message-docs",

@@ -61,3 +62,3 @@ "docs-deploy": "yarn docs && cp -r api-reference ../botmasterai.github.io/docs"

"dependencies": {
"debug": "^2.6.1",
"debug": "^2.6.6",
"lodash": "^4.17.4"

@@ -69,17 +70,17 @@ },

"devDependencies": {
"ava": "^0.18.2",
"ava": "^0.19.1",
"body-parser": "^1.17.1",
"botmaster-test-fixtures": "^2.1.0",
"coveralls": "^2.11.16",
"documentation": "^4.0.0-beta.18",
"eslint": "^3.17.0",
"eslint-config-airbnb": "^14.1.0",
"coveralls": "^2.13.1",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.0",
"eslint-plugin-ava": "^4.2.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-react": "^7.0.1",
"express": "^4.15.2",
"koa": "^2.0.1",
"nyc": "^10.1.2",
"request-promise": "^4.1.1"
"jsdoc-to-markdown": "^3.0.0",
"koa": "2.0.1",
"nyc": "^10.3.2",
"request-promise": "^4.2.1"
},

@@ -86,0 +87,0 @@ "author": "JD Wuarin <jwuarin@uk.ibm.com>",

@@ -5,21 +5,17 @@ # Botmaster

[![Coverage Status](https://coveralls.io/repos/github/botmasterai/botmaster/badge.svg?branch=master)](https://coveralls.io/github/botmasterai/botmaster?branch=master)
[![Dependency Status](https://gemnasium.com/badges/github.com/jdwuarin/botmaster.svg)](https://gemnasium.com/github.com/jdwuarin/botmaster)
[![Dependency Status](https://gemnasium.com/badges/github.com/botmasterai/botmaster.svg)](https://gemnasium.com/github.com/botmasterai/botmaster)
[![npm-version](https://img.shields.io/npm/v/botmaster.svg)](https://www.npmjs.com/package/botmaster)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](LICENSE)
Botmaster v3 is coming out.
Botmaster v3 out.
---
The code on this branch is for Botmaster v3. It will be published as soon as the
documentation for it is out and that the first couple of bot packages are out.
Botmaster v3 is virtually a complete rewrite of the framework. A lot of the syntax remains the same,
but there are quite a few breaking changes that were necessary in order to get the framework
to where we wanted it to be. It is now truly a micro-framework. With only 3 dependencies and without
to where we wanted it to be. It is now truly a micro-framework. With only 2 dependencies and without
relying on express anymore, Botmaster v3 is the only JS bot framework that gives as much control
as possible to the developer without losing its ease of use.
A migration documentation will be provided once v3 is published.
A migration documentation can be found at: http://botmasterai.com/documentation/latest/changelog.html#major-308
Botmaster is a lightweight chatbot framework. Its purpose is to integrate your existing chatbot into a variety of messaging channels - currently Facebook Messenger, Twitter DM and Telegram.

@@ -29,11 +25,6 @@

Find the whole documentation for the framework on: http://botmasterai.com/
Find the whole documentation for the framework on: http://botmasterai.com/documentation/latest
## Examples
Checkout the examples folder for some examples of how to use botmaster (adding more as they come in)
## License
This library is licensed under the MIT [license](LICENSE)

@@ -42,3 +42,3 @@ import test from 'ava';

method: 'POST',
uri: `http://localhost:3000/${botSettings.type}/webhook`,
uri: `http://localhost:3000/${botSettings.type}/webhook/endpoint`,
json: updateToSend,

@@ -66,3 +66,3 @@ };

requiresWebhook: true,
webhookEndpoint: 'webhook',
webhookEndpoint: 'webhook/endpoint',
type: 'express',

@@ -73,6 +73,12 @@ });

requiresWebhook: true,
webhookEndpoint: 'webhook',
webhookEndpoint: 'webhook/endpoint',
type: 'koa',
});
test('works with a webhook that has slash bot', arbitraryBotMacro, {
requiresWebhook: true,
webhookEndpoint: '/webhook/endpoint/',
type: 'express',
});
test('works with an express server AND both an express and a koa bot', (t) => {

@@ -79,0 +85,0 @@ t.plan(6);

@@ -5,5 +5,5 @@ import test from 'ava';

import Koa from 'koa';
import _ from 'lodash';
import request from 'request-promise';
import MockBot from '../_mock_bot';
import Botmaster from '../../lib';

@@ -94,2 +94,46 @@

// this test could also have been in add-bot. As it spans over both constructor and bot adding
test('should accept requests where expected when useDefaultMountPathPrepend is truthy', (t) => {
t.plan(3);
return new Promise((resolve) => {
const botmaster = new Botmaster({
useDefaultMountPathPrepend: false,
});
botmaster.on('listening', () => {
const bot = new MockBot({
requiresWebhook: true,
webhookEndpoint: 'webhook/endpoint',
type: 'express',
});
botmaster.addBot(bot);
t.is(Object.keys(botmaster.__serverRequestListeners).length, 1);
t.is(botmaster.bots.length, 1);
const updateToSend = { text: 'Hello world' };
const requestOptions = {
method: 'POST',
uri: 'http://localhost:3000/webhook/endpoint',
json: updateToSend,
};
request(requestOptions);
botmaster.use({
type: 'incoming',
controller: (onUpdateBot, update) => {
t.deepEqual(update.raw, updateToSend);
botmaster.server.close(resolve);
},
});
botmaster.on('error', () => {
botmaster.server.close(resolve);
});
});
});
});
test('should throw and error when server and port passed in settings', (t) => {

@@ -111,12 +155,2 @@ t.plan(1);

test('should throw and error when settings is an object and neither port nor server is passed', (t) => {
t.plan(1);
try {
const botmaster = new Botmaster({});
} catch (e) {
t.is(e.message.indexOf('If passing through settings,') > -1, true, 'Error message not same as expected');
}
});
test('when used with default botmaster server,' +

@@ -123,0 +157,0 @@ 'requestListener should return 404s to unfound routes', (t) => {

@@ -703,4 +703,4 @@ import test from 'ava';

test('sets up the outgoing middleware which is aware of update when manually set using sendOptions. or __createBotPatchedWithUpdate', (t) => {
t.plan(4);
test('sets up the outgoing middleware which is aware of update when manually set using __createBotPatchedWithUpdate', (t) => {
t.plan(2);

@@ -723,5 +723,2 @@ return new Promise(async (resolve) => {

try {
await bot.sendMessage(
outgoingMessageFixtures.textMessage(), { __update: mockUpdate });
// with a patchedBot

@@ -793,3 +790,2 @@ const patchedBot = bot.__createBotPatchedWithUpdate(mockUpdate);

t.is(update, receivedUpdate, 'Reference to update is not the same');
resolve();
}

@@ -805,2 +801,3 @@ },

t.is(body.sentRawMessage.message.text, 'Hello World!');
resolve();
},

@@ -812,2 +809,1 @@ });

});

Sorry, the diff of this file is not supported yet

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