Skip to content

See where your colleagues are. Tell your team you are working from home. A Node API you can use with a Slack bot and a web front-end.

License

Notifications You must be signed in to change notification settings

pebblecode/wfh-api

Repository files navigation

WFH API

What is this?

At pebble {code} we have a remote working policy, so to help find out who is working where we created a system to show the list of workers and their status. For more details see our blogpost Do you also work in a remote workplace? If you're using Slack you can easily deploy your own, and even start building things with the api. We have two services connecting to our api, one to send a summary email every weekday at 10am and another that pulls sickness and holiday information from our HR system.

This repo contains a node implementation of the pebble {code}the wfh api, more details see blogpost: http://pebblecode.com/blog/november-wfh-slack/

###functionality This adds the following slash commands in slack: /wfo /wfh

Slack slash command parameters

message: /wfh message:I'll be at home in my pants or /wfo message:I'll be at the stand up desk today default: /wfh default:wfo this allows your default location to be either wfh,wfo

The first time a user does /wfh, /wfo opts the user into the system. After that they will be shown in the api response /workers.

#Have your own instance of WFH. Deploy your own! You will need to configure Slack slash commands. use /wfh and /wfo to point to: /webhooks/slack, use a post request and add the tokens to the apps environment variables

#Deployment

  • Up to you. we currently use heroku.
  • Deploy your own.
    Deploy your own!
  • DB is couchdb and easily hosted on Cloudant create a database called: wfh
  • #####ENV variables Set the following to get your app up and running
    • COUCHDB_USERNAME

    • COUCHDB_PASSWORD

    • COUCHDB_URL

    • COUCHDB_PORT

    • COUCHDB_NAME

    • SEGMENT_IO_WRITE_KEY (optional) used for tracking and graphs to work out averages for sickness, holiday, out of office etc.

    • SLACK_TOKEN used to get a users profile see slack docs.

    • ADMIN_PASSWORD for admin user, basic auth password

#Development && installation Install CouchDB and run. For a nicer couch db ui install: npm i -g fauxton then in a new shell run fauxton

npm i && npm i -g nodemon start server locally npm run dev

When NODE_ENV === 'development' connection will be made with localhost couchdb.

###Configuration for local development. Copy config.template.js > config.js and complete the default fields getEnv('ENV_VAR','DEFAULT_VALUE'), to get a slack token visit: https://api.slack.com/web

#Endpoints

path method payload details
/workers GET get all workers, used by email cron and tv display
/workers POST {"name":"Jon Snow", "email":"[email protected]", status:"Sick" } create a new worker, "message": "your message" is optional
/workers PUT {"email":"[email protected]", "status":"Holiday"} Update status for worker
/workers/id DELETE Delete a worker by uuid

#AUTH is BASIC auth and password is a hashed bcrypt stored in the ADMIN_PASSWORD env variable.

###Integrations The api has full CRUD functionality, see the docs for more details. So this is open for your own integrations. We've used this to integrate with Tribe HR, send Emails at 10am or display on a TV in the office.

###Architecture image of architecture

#Helpful Links

#Contributing Awesome! Get in touch first, make an issue to discuss your change and we can go from there. Will be followed by a PR.

TODO:

  • Add functionality to delete workers (use slack as source of truth. slack api)
  • Websocket support for connecting devices
  • Docker deployment - fix bcrypt build errors: kelektiv/node.bcrypt.js#368

###We'd love to hear from you Let us know what you do with WFH bot.

About

See where your colleagues are. Tell your team you are working from home. A Node API you can use with a Slack bot and a web front-end.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published