Code Monkey home page Code Monkey logo

slapp-firebase-example's Introduction

slapp-firebase-example

An example Slapp Slack App using Firebase as the persistence layer. A primary goal of this repo is to serve as an example of you you might integrate a custom persistence layer w/ Slapp.

Expects the following environment variables:

  • PORT - port to start http server on - defaults to 3000
  • DOMAIN - domain name - defaults to pulling from host headers on requests
  • SLACK_VERIFY_TOKEN - Your Slack App's verify token
  • SLACK_CLIENT_ID - Your Slack App's Client ID
  • SLACK_CLIENT_SECRET - Your Slack App's Client Secret
  • FIREBASE_DB_URL - Your Firebase project's Database URL
  • FIREBASE_SERVICE_ACCOUNT_BASE64 - Your Firebase project's ID

To create your FIREBASE_SERVICE_ACCOUNT_BASE64 value you'll want to head to your Firebase project's Service Accounts settings and generate a new Private Key json file. You'll need to base64 encode the contents of the file to be able to set it as an environment variable.

base64 /path/to/service-account.json

For development you can set your environment variables in an env.sh file (which is .gitignored for you), and then just source it.

export PORT="8080"
export SLACK_VERIFY_TOKEN="your-slack-verify-token"
export SLACK_CLIENT_ID="your-slack-app-client-id"
export SLACK_CLIENT_SECRET="your-slack-app-client-secret"
export FIREBASE_DB_URL="your-firebase-url"
export FIREBASE_SERVICE_ACCOUNT_BASE64="base64 encoded service account key file contents"

Getting Started

You'll need to setup a new Slack App and add a Bot User, as well as enable Event Subscriptions. Pick any username for your Bot User, and for your Event Subscrition, use the following details:

  • Request URL: https://<your-domain>/slack/event
  • Add the following Bot Events
    • message.channels
    • message.groups
    • message.im
    • message.mpim

A Firebase project is also required. Slack Team data from the "Add to Slack" OAuth flow, as well as conversation state is stored there.

Running App

Once you have your app running, if you visit the root, https://<your-domain>/ it will render a page with an "Add to Slack" button you can use to add it to one of your Slack teams and start sending it messages.

Try asking the bot for help in a direct message

image

Try changing the messages the bot is listening for to get a feel for how things work by looking in lib/slapp.js

slapp-firebase-example's People

Contributors

selfcontained avatar

Stargazers

 avatar Rafael Klaessen avatar Pascal Weiland avatar Jean Runnells avatar Zachary Mayberry avatar Heechul Ryu avatar Jenny Veens avatar hacker-box.com avatar Patrick Walsh avatar Son avatar Sjoerd Bodbijl avatar Sokratis Vidros avatar  avatar  avatar Will Dearman avatar Jeremy Mack avatar N. Darville avatar

Watchers

James Cloos avatar  avatar

slapp-firebase-example's Issues

Firebase config file shouldn't be in the repository

Hello!

I'm wondering about this on your README:

Also expected is a Firebase Service account key file located in the root of the project, named firebase.json.

Since BeepBoop actually builds the image from Dockerfile, then firebase.json must be in the repository, which is very bad practice since it contains sensitive information like the private key.

Reading up on Firebase's docs, I think that the information contained in firebase.json could be passed via ENV vars, but I'm counting 10 different values in it, which would make booting up the app in BeepBoop a very tedious and error prone process.

Maybe I could try to pass the whole of the JSON file as a string blob in a single ENV, but who knows if that's going to work with all the weird characters.

So right now I'm torn between an unacceptable method (config file in the repo) or a very tedious and error prone one (passing 10 different ENV vars).

But I might be missing something?

Thanks!

Juan

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.