wingbot-intercom

1.0.3 • Public • Published

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

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.

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

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

intercom.processEvent(body) ⇒ Promise.<Array.<{message:object, pageId:string}>>

Process Facebook request

Kind: instance method of Intercom
Returns: Promise.<Array.<{message:object, pageId:string}>> - - unprocessed events

Param Type Description
body object event body

intercom.verifyRequest(body, headers) ⇒ Promise

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

Processor : Object

Kind: global typedef

Param Type
processMessage function

Package Sidebar

Install

npm i wingbot-intercom

Weekly Downloads

6

Version

1.0.3

License

MIT

Unpacked Size

468 kB

Total Files

15

Last publish

Collaborators

  • wingbot.ai