// Blog
Slack Notifications for Clarify.io
Originally published on the Clarify.io blog. View archived copy.
We’ve previously covered how to plug Slack+Twilio+Clarify together to place and transcribe phone calls. While that works beautifully, we just need to know what’s going on. For that, we have Slack Notifications.
In talking with a customer this week, I learned they wanted to use our status callbacks to keep their team up to date via Slack Notifications. As a major Slack user myself, that made sense so I took it on.
Skip down to the results or grab the Slack->Clarify.io Gist if you want to skip the rest of my discussion.
There were a few items to tackle:
- First, we don’t have the same fields or structure that Slack callbacks expect so we need to extract the fields and put them into the right structure.
- Next, we generate a lot of callbacks – one for each file retrieval attempted, one for each insight (4 available at the time of this writing), and one when the entire job is done. Without some thought, we could flood ourselves.
- Finally, when errors appear, we need to make sure they aren’t lost in the flood.
The resulting code takes care of all three issues. I separated the types of callbacks we could get and then use Slack’s built-in emoji warning sign for actual errors. We could still turn off some of the notifications but that’s trivial.
The Results
While it looks like a lot of code at first glance, it’s relatively simple. To use this, create an incoming webhook for your Slack channel, upload this file to a server with PHP, and then change your Clarify code from this:
curl --data "media_url=http://media.clarify.io/audio/books/dorothyandthewizardinoz_01_baum_64kb.mp3" \
--data "name=Dorothy and the Wizard of Oz" https://api.clarify.io/v1/bundles \
--X POST --header "Authorization: Bearer myapikey"
to this:
curl --data "media_url=http://media.clarify.io/audio/books/dorothyandthewizardinoz_01_baum_64kb.mp3" \
--data "notify_url=http://yourdomain.com/clarify-slack-converter.php" \
--data "name=Dorothy and the Wizard of Oz" https://api.clarify.io/v1/bundles \
--X POST --header "Authorization: Bearer myapikey"
Just adding the notify_url parameter will keep your team up to date with a Slack Notifications whenever you create a new bundle with us.
And while you’re at it, check out our Slack channel to talk with the team and get help when you need it.