# wingbot-intercom

> Intercom integration for wingbot.ai

Latest version **1.0.3** (published 2019-05-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install wingbot-intercom
pnpm add wingbot-intercom
yarn add wingbot-intercom
bun add wingbot-intercom
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-05-30 |
| First published | 2019-05-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^8.0.0 |
| Dependencies | 2 |
| Unpacked size | 457.5 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | wingbot.ai |
| Maintainers | wingbot.ai |
| Keywords | wingbot, intercom, chatbot, framework |

## Links

- npm: https://www.npmjs.com/package/wingbot-intercom
- Repository: https://github.com/wingbotai/wingbot-intercom
- Homepage: https://github.com/wingbotai/wingbot-intercom#readme
- Issues: https://github.com/wingbotai/wingbot-intercom/issues
- npm.io page: https://npm.io/package/wingbot-intercom

## Dependencies (2)

- [request](https://npm.io/package/request.md) ^2.88.0
- [request-promise-native](https://npm.io/package/request-promise-native.md) ^1.0.7

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2019-05-30
- 1.0.2 — 2019-05-30
- 1.0.1 — 2019-05-30
- 1.0.0 — 2019-05-30

## README

# Intercom connector for wingbot.ai bot

It's easy now to use the wingbot.ai as an automation backend for Intercom.

![wingbot bot in the Intercom](wingbot-intercom.png)

## Setting up the Intercom

1. **Create an Intercom application**

    you'll get an access token, which you'll be able to use as `intercomAppToken`.

2. **Set up the webhook**

    Subscribe the bot to following channels

    - `conversation.user.created`
    - `conversation.user.replied`
    - `conversation.admin.assigned`

3. **Create a Bot admin user**

    You'll use an ID of the user as a `botAdminId` param.

4. **Make additional setup**

    These steps are required to make the bot working properly:

    - set the Bot admin user as a default assignee
    - turn off the work hours
    - set up the welcome message for all chat users

5. **Use team (or admin user) ID as a Handover app ID**

    To pass thread to team or user use it's ID as an application ID in pass thread command.

## Setting up the bot

And don't forget to **disable `autoTyping` and `autoSeen` feature and all handover related interactions.**

```javascript
const { Router, Bot } = require('wingbot');
const { Intercom } = require('wingbot-intercom');

const bot = new Bot();

const processor = new Processor(bot);

const intercom = new Intercom(processor, {
    botAdminId: '123',
    intercomAppToken: '456'
});

// the route
module.exports.bot = async (req, res) => {
    const { body, headers } = req;

    await intercom.verifyRequest(body, headers);

    await intercom.processEvent(body);
};
```

-----------------

# API
## Classes

<dl>
<dt><a href="#Intercom">Intercom</a></dt>
<dd><p>BotService connector for wingbot.ai</p>
</dd>
</dl>

## Typedefs

<dl>
<dt><a href="#Processor">Processor</a> : <code>Object</code></dt>
<dd></dd>
</dl>

<a name="Intercom"></a>

## Intercom
BotService connector for wingbot.ai

**Kind**: global class  

* [Intercom](#Intercom)
    * [new Intercom(processor, options, [senderLogger])](#new_Intercom_new)
    * [.processEvent(body)](#Intercom+processEvent) ⇒ <code>Promise.&lt;Array.&lt;{message:object, pageId:string}&gt;&gt;</code>
    * [.verifyRequest(body, headers)](#Intercom+verifyRequest) ⇒ <code>Promise</code>

<a name="new_Intercom_new"></a>

### new Intercom(processor, options, [senderLogger])

| Param | Type | Description |
| --- | --- | --- |
| processor | [<code>Processor</code>](#Processor) | wingbot Processor instance |
| options | <code>object</code> |  |
| options.botAdminId | <code>string</code> | id of the bot user in Intercom |
| options.intercomAppToken | <code>string</code> | OAUTH token to authorize Intercom requests |
| [options.passThreadAction] | <code>string</code> | trigger this action for pass thread event |
| [options.requestLib] | <code>function</code> | request library replacement for testing |
| [options.uri] | <code>string</code> | override intercom URL |
| [senderLogger] | <code>console</code> | optional console like chat logger |

<a name="Intercom+processEvent"></a>

### intercom.processEvent(body) ⇒ <code>Promise.&lt;Array.&lt;{message:object, pageId:string}&gt;&gt;</code>
Process Facebook request

**Kind**: instance method of [<code>Intercom</code>](#Intercom)  
**Returns**: <code>Promise.&lt;Array.&lt;{message:object, pageId:string}&gt;&gt;</code> - - unprocessed events  

| Param | Type | Description |
| --- | --- | --- |
| body | <code>object</code> | event body |

<a name="Intercom+verifyRequest"></a>

### intercom.verifyRequest(body, headers) ⇒ <code>Promise</code>
Verify Facebook webhook event

**Kind**: instance method of [<code>Intercom</code>](#Intercom)  
**Throws**:

- <code>Error</code> when authorization token is invalid or missing


| Param | Type | Description |
| --- | --- | --- |
| body | <code>string</code> \| <code>Buffer</code> | parsed request body |
| headers | <code>object</code> | request headers |

<a name="Processor"></a>

## Processor : <code>Object</code>
**Kind**: global typedef  

| Param | Type |
| --- | --- |
| processMessage | <code>function</code> |

---
_Source: https://npm.io/package/wingbot-intercom · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
