1.0.5 • Published 7 years ago

servicenow-slackbot v1.0.5

Weekly downloads
6
License
-
Repository
-
Last release
7 years ago

servicenow-slackbot

Slackbot for users to submit ServiceNow ticket requests. This Slackbot is based on the Sample Message Menus example from https://github.com/slackapi/sample-message-menus-node.

Setup: before running slackbot.js, you must install Node.js and npm (the Node package manager). You can download Node.js here: https://nodejs.org/en/download/ You can check if node is installed by typing the command

node -v

into the terminal. If you get output, it is installed; no output means it isn't. Similarly,

npm -v

will tell you whether npm is installed.

Slack API Setup

Create a Slack app

To start, create an app at api.slack.com/apps and configure it with a bot user, event subscriptions, interactive messages, and an incoming webhook. This sample app uses the Slack Event Adapter, where you can find some configuration steps to get the Events API ready to use in your app.

Bot user

Click on the Bot user feature on your app configuration page. Assign it a username (such as @servicenowbot), enable it to be always online, and save changes.

Event subscriptions

Turn on Event Subscriptions for the Slack app. You must input and verify a Request URL, and the easiest way to do this is to use a development proxy as described in the Events API module. The application listens for events at the path /slack/events:

  • path + /slack/events

Create a subscription to the team event team_join and a bot event for message.im. Save your changes.

Interactive Messages

Click on Interactive Messages on the left side navigation, and enable it. Input your Request URL:

  • path + /slack/actions

(there's a more complete explanation of Interactive Message configuration on the Node Slack Interactive Messages module).

Incoming webhook

Create a channel for your team to complete ServiceNow tickets (such as #servicenowhelp). Add an incoming webhook to your app's configuration and select this team. Complete it by authorizing the webhook on your team.

Environment variables

You should now have a Slack verification token (basic information), slackbot token, and webhook URL (install app).

If you're developing locally:

  1. Create a new file named .env (see .env.sample) within the directory and place the values as shown below
  2. Download the dependencies for the application by running npm install. Note that this example assumes you are using a currently supported LTS version of Node (at this time, v6 or above).
SLACK_VERIFICATION_TOKEN=xxxxxxxxxxxxxxxxxxx
SLACK_BOT_TOKEN=xoxb-000000000000-xxxxxxxxxxxxxxxxxxxxxxxx
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/xxxxxxxxx/yyyyyyyyy/zzzzzzzzzzzzzzzzzzzzzzzz

Usage

Once you have app is installed, generate a localtunnel temporary URL using this command:

lt --port 3000 --subdomain <projectname>

Start the app by running (npm start). With app and localtunnel running, direct message @servicenowbot to see the app in action!