I’m also a co-founder of a makerspace in Orlando called Factur. As Factur started to grow, it became apparent that we needed a way to communicate between our members, especially between the core founding team because we need to coordinate for in-person board meetings. I suggested that we try Slack as a collaborative tool and overall it’s been great…except for the handful of people who never log into Slack. Right now there’s no Slack mobile app for Windows Phone, and even for people who do have the app, if they don’t have notifications turned on, they’ll never know there’s an action required by them, such as to pick a time they are available for a board meeting.
The workaround so far has been for someone to manually call or text the person ignoring Slack and say “HEY, LOG INTO SLACK YOU SLACKER!”, but that’s inefficient and an undue burden. But what if you could automate that somehow? That got my wheels turning.
I’d never played with Slack’s API, but I knew they have one so I started poking around their site. I thought maybe if I could make a slash command and then have Slack send it to Tropo to send out SMS messages to all the board members, that would make it easy…something like:
/slackSMS Everyone needs to log into slack and pick a time for the next board meeting!
So yesterday I did a quick integration that does exactly that. It’s not full-featured, but it shows a simple way to send out SMS messages directly from the Slack command line using Tropo Scripting.
A couple of things to note before you try this:
- You need to be an administrator of your Slack account
- You need a Tropo account with outbound SMS enabled (open a support ticket in your Tropo account to enable outbound SMS)
Set up your Tropo App
- Log into Tropo and create a new scripting application. (Make sure you have outbound SMS enabled on your Tropo Account)
- Under scripting choose “New Script”.
- Copy the code from my Github Slack Tropo SMS example and paste it into the code window.
- Name the file slacktroposms.rb
- Save and Close the window
- Choose any U.S. phone number and click “Create App”
- Now that your app is created you’re going to want to copy the phone number assigned to your app and click Edit Script (doesn’t matter which one because they both point to the same script…slacktroposms.rb)
- Go down to the line that says :callerID => “+14155551212” and replace the phone number with the one that’s assigned to your app.
- Save and close that window.
- Scroll down to API keys. Under the Messaging one click “Copy to Clipboard”
- Take a break, pat yourself on the back and watch this video.
Set up your Slack Slash Command
- Ensure you have Administrator privileges on your Slack account and login via the web.
- From your Slack home page, scroll down to “Integrations” and choose “Add new Integration”
- Under DIY Integrations & Customizations, find “Slash Commands” and click “Add”
- Under “Choose a Command” type /slacksms (you can customize this to your liking) and then click “Add Slash Command Integration”
- Open a text editor and paste your API key there for safe keeping.
- Copy the following URL and paste it into the same text editor: http://api.tropo.com/1.0/sessions?action=create&token=myToken&myString=Slack+notification+from&myNumbers=14155551212,16507771313
- Replace the myToken part of that URL with the API Key you copied from Tropo
- Change the phone number(s) to the numbers of the people you want to notify. Note: you can use just one number (such as your own) for testing, but if you have multiple numbers just use the same format and separate by a comma.
- Copy that entire URL, complete with your Tropo API and your phone number and paste into your Slack Integration Settings in the URL field
- Change Method to “GET”
- Click Save Integration
Test your Integration
- Open up Slack and choose a channel
- type /slacksms hello world
- You should see a response from Slackbot that looks like ”
- Don’t worry…no one in the room will see that…the important thing is that you see the <success>true</success>
- Wait for your text message. You should see a message that says “Slack notification from Bob: hello world” (whereas Bob is whatever your Slack username is)
But what if it didn’t work?
Bugger! But here are some troubleshooting tips:
- Make sure you have outbound SMS enabled in your Tropo account
- Make sure you copied your Tropo phone number correctly into the Tropo script.
- Ensure you copied your Tropo API key into the URL correctly
- Make sure you put your mobile phone number in correctly
Obviously we’re hard-coding phone numbers here, but it would be nice to use the phone number in each user’s Slack profile. For ease, I chose to use Tropo’s Scripting platform for this example, but Slack has a more robust REST/JSON API to access user profile data, so we could change this whole application to a Tropo WebAPI application and grab each user’s phone number in a specific channel to send them messages without hard coding.
Also, you can write some code to capture any replies and post them back to Slack. But that’s for a future post 🙂