Camayak to Slack
At TCU 360, we publish from Camayak to our Drupal CMS using copy-paste, so getting notifications in Slack when stories are ready to post is a big help.
camayak-to-slack allows Slack to function as a Camayak publishing destination. When stories are published, a message is pushed to Slack with the story's byline, headline, teaser and some info on the types of media attached.
This app, which runs on Node.js, should easily run on Heroku's free tier. It receives a webhook from Camayak, grabs the story from Camayak's Content API and pushes it to by posting an incoming webhook.
- Push this repo to Heroku. Set the Heroku environment variable
HEROKU_URLto the app's URL (ex: http://your-app.herokuapp.com).
- Add an incoming webhook in Slack. Don't worry about any of the settings (bot name, etc.) because those will be set by this app. Set the environment variable
SLACK_HOOK_URLto the webhook's URL. Optionally, set
SLACK_CHANNELto the channel you'd like notifications pushed to. It'll post to #general by default.
- Setup a new Content API publishing destination in Camayak. Use the Heroku app's URL (preferably the
httpsversion) as the Webhook notify URL and add a secret Shared secret of your choice. Set the
CAMAYAK_SUBDOMAINenvironment variables accordingly.
- That's it! You should now be receiving notifications in Slack for any Camayak items that are set to publish to your new Slack publishing destination.
This was a one-day project to add a little efficiency to our lives and see what was possible with the Camayak API, so there's probably plenty that can be improved (for one, we don't handle retract events or distinguish between updates and first-time publication). That said, pull requests and issue reports are most appreciated.
The MIT License (MIT)
Copyright (c) 2014 TCU Student Media
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.