Intercom integration for wingbot.ai
npm install wingbot-intercomIt's easy now to use the wingbot.ai as an automation backend for 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.
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);
};
``
-----------------
BotService connector for wingbot.ai
ObjectKind: global class
* Intercom
* [new Intercom(processor, options, [senderLogger])](#new_Intercom_new)
* .processEvent(body) ⇒ Promise.<Array.<{message:object, pageId:string}>>
* .verifyRequest(body, headers) ⇒ Promise
| Param | Type | Description |
| --- | --- | --- |
| processor | Processor | wingbot Processor instance |
| options | object | |
| options.botAdminId | string | id of the bot user in Intercom |
| options.intercomAppToken | string | OAUTH token to authorize Intercom requests |
| [options.passThreadAction] | string | trigger this action for pass thread event |
| [options.requestLib] | function | request library replacement for testing |
| [options.uri] | string | override intercom URL |
| [senderLogger] | console | optional console like chat logger |
Kind: instance method of Intercom
Returns: Promise.<Array.<{message:object, pageId:string}>> - - unprocessed events
| Param | Type | Description |
| --- | --- | --- |
| body | object | event body |
Kind: instance method of Intercom
Throws:
- Error when authorization token is invalid or missing
| Param | Type | Description |
| --- | --- | --- |
| body | string \| Buffer | parsed request body |
| headers | object | request headers |
Object| Param | Type |
| --- | --- |
| processMessage | function |