slack-contentful
slack-contentful copied to clipboard
:speech_balloon: Track Contentful entries changes on Slack, without moving a finger.
Slack Contentful

Slack-contentful allows users to recieve push notifications on specified Contentful updates to a designated Slack channel. Updates are based on the following events: create, save, auto save, archive, unarchive, publish, unpublish, and delete.

Requirements
- Slack Privileages to integrate Incoming Webhooks
- Node.js
- Contentful Access to add outgoing hooks
Automated Set Up w/ Heroku
Allow for incoming hooks to your team's Slack
Deploy the server to your own Heroku instance, and set SLACK_WEBHOOK to the incoming hook url from the integration above
It's preferred to set your locale, and leave your bot's emojis and username blank as these can be edit through the "Incoming Hooks" page by other team members.
Manual Set Up
Configuration
The configuration of the bot are set with environment variables using an .env file. Please look at the example.env file of possible configurations, and create an updated .env file before you deploy.
Available Configuration Options:
| ENV Variable | Required | Description | Default Value |
|---|---|---|---|
| SLACK_WEBHOOK | Y | The webhook Url provided by the incoming hooks | N/A |
| SLACK_CHANNEL | Y | The slack channel to send notifications | N/A |
| ENTRIES | N | A comma seperated list of Contentful Entry IDs you want to be notified of | N/A |
| TRACK_ALL | N | Set this to true if all Contentful updates should be notified, this will override tracked entries | false |
| LOCALE | N (but preferred) | Contentful Locale to be tracked, currently only supports up to 1 | en-US |
| PORT | N | The port for the node server to run on | 5000 |
| UPDATE_COLOR | N | Hex color for updates posted | #27ae60 |
| BOT_USERNAME | N | The bot's username | ContentfulUpdates |
| BOT_EMOJI | N | The bot's icon | pencil2 |
| LARGE_PREVIEW | N | Should a large image preview be used for an asset notification | false |
Here's an example, of how your .env would look like. .env
SLACK_WEBHOOK = https://hooks.slack.com/services/TA123ka9/A123910a9d8/mkas929199sad83lmk7h
SLACK_CHANNEL = #ContentfulFeed
ENTRIES = 6OFbybzxM4WOCuIO4qo8Qs,6aFz3qcuPe0eA8kwQm0Ume,6a232jal2eA8kwQm0Ume,etc
LOCALE = en-UK
PORT = 5000
UPDATE_COLOR = #27ae60
BOT_USERNAME = ContentfulUpdates
BOT_EMOJI = bomb
LARGE_PREVIEW = true
Deploying Steps
- Set up the address of your server to configure where Contentful outgoing hooks should be sent to. (ex: myapp.heroku.com, botcontentful.mycompany.com)
- Clone or download/unzip this repo to your serer
- Adjust your
.envfile as outlined above - Install Node.js on your server if not done so already
- Install repo dependencies
$ cd to/repo
$ npm install
- Start the server
$ npm start
Contentful Configuration
- Go to Contentful.
- Login with your credentials.
- Locate the cog icon labeled settings, and click on 'webhooks'.
- Hit 'New Webhook', and enter your server address in the URL bar.
- Click 'Create Webhook'.
- The notifications can be customized based on particular events. examine config below

NOTE: AUTO_SAVE event will always be triggered after PUBLISH events. To prevent redudant AUTO_SAVE
events, uncheck AUTO_SAVE triggers.
Post Deployment - Test & Debugging
After your app has deployed, go to your server url and go to the /debug endpoint to verify your settings, and help with debugging any potential issues.
Example:
http://myherokuapp.heroku.com/debug
If you've successfully deployed, you should get a successful message stating Successful Set-up along with a table of configurations to verify against as depicted below.

If set up was unsuccessful, you should get a message to verify your configurations, along with important configurations that the server has set up.

Contribute
If you would like to contribute to this project, take a look at the wiki to get started.
Feel free fork and submit PRs, if applicable reference the issue, or explain the intent of the PR. If it's suitable, I'll go ahead and merge it.

