How to integrate ServiceNow & Slack’s Slash Commands

  • A slack channel — if you don’t have one, you can create one here
  • A slack developer account — You can create one here
  • A ServiceNow instance — you can get developer instance if you create an account here

Step 1. Create the Processor

Go to System Definition > Processors. Click New.

New Processor

Step 2. Make the processor public

The processor will currently require credentials to be accessed, but Slack doesn’t have credentials. So, we will have to make it a public page. Type in sys_public.list into the search bar on the left and hit enter. It will bring you to a list of all the public pages for your instance. Click New

New Public Page

Step 3. The Slash Command

Go back to your Slack App window. We are now going to get Slack talking to ServiceNow. Click Slash Commands under Features

Create New Command

Step 4. First Test

Go to your slack Channel and enter this command /test data and hit enter. Slack will now send a post to your processor’s URL endpoint, but it won’t show anything happening on the Slack side. There will be logs of all the headers, and parameters as well as the method type in ServiceNow.

Step 5. Build the Staging Table

Using the logs from our previous test, we are now going to build our staging table.

  • response URL
  • user_id
  • team_id
  • text
  • channel_name
  • token
  • command
  • channel_id
  • user_name
  • team_domain
  • method
  • querystring
  • x-forwarded-host
  • accept
  • x-forwarded-proto
  • accept-encoding
  • content-type
  • host
  • x-forwarded-for
  • content-length
  • user-agent

Step 6. Replacing the Processor Script

Replace all of the code in your processor’s script with this code:

Step 7. Test the slash command again

Go back to your channel & run your slash command. Then go back to the list view of the table you created in step 6. You should see a new record. Open up the record & make sure all of the data is populated. You may have misspelled something the first time, just delete the dictionary entry and add a new one with the correct spelling. Rerun your slash command if this happens to confirm it works correctly

Step 8. Responding/Running Server side actions

From this point, you can do anything with this data. Create, update, delete, send emails, start workflows, etc. However, I suspect that you will be likely to want to respond to the command with a slack message from ServiceNow. That is where Joey Day’s tutorial comes in handy.


Highly Recommended: Adding Some Security

When we created the processor & made it public, we made it available for anyone with the URL, and I mean anyone, to access it. So, we will add a bit of security to this now. As we discovered before, when a slack app sends a slash command post to an endpoint it sends many pieces of data. One of them is the Token. The Token is a code that validates that the command was from your Slack application. This is a very important piece of information and should be kept secret.

  1. Validate the REST Call using the token field


Slack is a really cool tool and building an integration with it & ServiceNow opens the doors to many possibilities. This was a really fun project for me and I really hope you find it helpful & useful. If you really liked this tutorial: share it & follow me on twitter, Jeff Manville. I will probably post more tutorials on integrating Slack & ServiceNow as well as other integrations.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jeff Manville

Jeff Manville

I like helping people with Code & Math. I try to make everything I do a version of that.