0.1.3 • Published 4 years ago

botkit-portal-slack v0.1.3

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

botkit-portal-slack

Integrate simple customer support in your Botkit Slack app

Install Package

Add this package to your project using npm:

npm install --save botkit-portal-slack

Import the adapter class into your code:

const { Portal } = require('botkit-portal-slack');

Install Portal slack app in your Slack workspace

When you install Portal into your Slack workspace, you will receive two tokens: a portal token (starts with portalt_) and a client secret (portalc_). These are required for your app to interact with the Portal service

Use Portal in your App

Configure the plugin with the URI of your app instance, and the portal token and client signing secret you'll receive when you install the Portal app.

The plugin defaults to listening for the following commands:

You can configure specific slash ('/') and at ('@') commands for your bot using the following format:

{
    listeners: {
        keywords: [list of keywords] // use this if you have common keywords you want to listen for afer all app /commands
        slash_command: [
            {
                <slash command>: [list of secondary keywords (e.g.: support, help, feedback)]
                <another command>: [] //an empty list tells portal to respond to the /command directly. This allows it to pull all text from the command as content - e.g.: /support I have a major complaint
            }
        ],
        at_mention: [list of secondary keywords], //If no secondary keywords are specified, then we respond to all @mention DMs
    }
}

One last option is to enable/disable passthrough - keeping passthrough enabled will have Portal pass all messages on to your bot once it's done, while disabling it will have Portal stop processing messages directed to Portal once they are processed. Passthrough is enabled by default, but we recommend disabling it if you have no plans to log/register/conduct additional processing.

 {
     ...
     passthrough: true,
     ...
 }

Finally, initialize the plugin and install into your app's Botkit controller: Initialize the plugin:

// or for legacy botkit apps (0.7/* and below)
let Portal = require('botkit-portal-slack')

let portal = Portal.slack({
    receiver_url: 'https://your_app_URI/', 
    portal_token: 'token_from_portal_setup', // DO NOT commit the actual token into your source code
    client_secret: 'other_token_from_portal', // DO NOT commit this token either.
    listeners: {} // see the discussion of listeners above
});

NOTE - the receiver URL should be the same base URL that you registered with Slack to receive Event API calls. Do not include /slack/receive or any other secondary routes, as Portal generates its own routes for handling cross-platform messages.

To install the plugin on bots using Botkit (v. 0.7.* and below):

controller = new Botkit.slackbot(config)

portal.init(controller)

Once registered, Botkit will automatically integrate Portal into your bot, where it will listen for support/helpdesk/feedback requests and pass support conversations back and forth between your app and your Slack workspace.

Requirements

Botkit (v 0.7.5 and below)

Node (>8.0.0)