Code Monkey home page Code Monkey logo

slack-contentful's Introduction

Slack Contentful Slack Icon Contentful Icon

GitHub tag Travis branch Dependency Status XO code style

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.

Example Update

Requirements

Automated Set Up w/ Heroku

Allow for incoming hooks to your team's Slack

Add to Slack

Deploy the server to your own Heroku instance, and set SLACK_WEBHOOK to the incoming hook url from the integration above

Deploy

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

  1. Set up the address of your server to configure where Contentful outgoing hooks should be sent to. (ex: myapp.heroku.com, botcontentful.mycompany.com)
  2. Clone or download/unzip this repo to your serer
  3. Adjust your .env file as outlined above
  4. Install Node.js on your server if not done so already
  5. Install repo dependencies
$ cd to/repo
$ npm install
  1. Start the server
$ npm start

Contentful Configuration

  1. Go to Contentful.
  2. Login with your credentials.
  3. Locate the cog icon labeled settings, and click on 'webhooks'.
  4. Hit 'New Webhook', and enter your server address in the URL bar.
  5. Click 'Create Webhook'.
  6. The notifications can be customized based on particular events. examine config below

Contentful Event Triggers

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.

successful set up

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

unsuccessful 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.

slack-contentful's People

Contributors

brh55 avatar timbeyer avatar jlegrone avatar

Stargazers

 avatar Sarah Federman avatar Kevin Dial avatar Connor Bär avatar matias avatar Riley Spiller avatar Spencer Schoeben avatar Steven Yee avatar  avatar Phan Le avatar Paul Dariye avatar Abdul Rehman Khawar avatar Ross Lemenille avatar Johan Borestad avatar James Campbell avatar Dani Hodovic avatar Boris Bügling avatar Joshua Kemmerer avatar Rudy Affandi avatar Pat Thiel avatar Tom Bicknell avatar Christoph Grabo avatar

Watchers

James Cloos avatar  avatar

slack-contentful's Issues

Find better alternative to prevent duplicated Slack messages

When publishing a change, Contentful updates it across various CDNs, and submits individual outgoing hook for each CDN update. Currently, the bot prevents the same EntryID within a 10 minute span to be considered a "new publish change." Since most users are concern about when a publish change is actually happening, it makes sense. But ideally it would be nice to find a better way to filter duplicates, and will allow for a more specific level of notifications.

Modularize Routes

Break out the routes in server.js to make it easier to manage as things get larger.

Allow users to update entries list through a Slack message versus static ENV

Ideally, a user should be able to run a command from Slack like below.

/contentful update

Afterwards, the Node bot should respond by informing them the current list of possible Entries, and for them to replace it with a new list of Entries. You would probably have to move the EntriesList from ENV to cache.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.