Intercom connector for wingbot.ai bot
It's easy now to use the wingbot.ai as an automation backend for Intercom.
Setting up the Intercom
-
Create an Intercom application
you'll get an access token, which you'll be able to use as
intercomAppToken
. -
Set up the webhook
Subscribe the bot to following channels
conversation.user.created
conversation.user.replied
conversation.admin.assigned
-
Create a Bot admin user
You'll use an ID of the user as a
botAdminId
param. -
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
-
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.
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
- Intercom
-
BotService connector for wingbot.ai
Typedefs
-
Processor :
Object
Intercom
BotService connector for wingbot.ai
Kind: global class
-
Intercom
- new Intercom(processor, options, [senderLogger])
-
.processEvent(body) ⇒
Promise.<Array.<{message:object, pageId:string}>>
-
.verifyRequest(body, headers) ⇒
Promise
new Intercom(processor, options, [senderLogger])
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 |
Promise.<Array.<{message:object, pageId:string}>>
intercom.processEvent(body) ⇒ Process Facebook request
Kind: instance method of Intercom
Returns: Promise.<Array.<{message:object, pageId:string}>>
- - unprocessed events
Param | Type | Description |
---|---|---|
body | object |
event body |
Promise
intercom.verifyRequest(body, headers) ⇒ Verify Facebook webhook event
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
Processor : Kind: global typedef
Param | Type |
---|---|
processMessage | function |