1.0.3 • Published 5 years ago

wingbot-intercom v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

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

Typedefs

Intercom

BotService connector for wingbot.ai

Kind: global class

new Intercom(processor, options, senderLogger)

ParamTypeDescription
processorProcessorwingbot Processor instance
optionsobject
options.botAdminIdstringid of the bot user in Intercom
options.intercomAppTokenstringOAUTH token to authorize Intercom requests
options.passThreadActionstringtrigger this action for pass thread event
options.requestLibfunctionrequest library replacement for testing
options.uristringoverride intercom URL
senderLoggerconsoleoptional 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

ParamTypeDescription
bodyobjectevent body

intercom.verifyRequest(body, headers) ⇒ Promise

Verify Facebook webhook event

Kind: instance method of Intercom
Throws:

  • Error when authorization token is invalid or missing
ParamTypeDescription
bodystring | Bufferparsed request body
headersobjectrequest headers

Processor : Object

Kind: global typedef

ParamType
processMessagefunction