Giter VIP home page Giter VIP logo

fika's Introduction

fika

The fika slackbot

Add Fika to Slack!

About the Project

Currently a work in progress / Proof of concept

Intention of this project is to automatically generate small personal 1:1 meetings among members of a slack community, while not disrupting the primary purpose of the channel itself, and respecting a rate-of-enagagement that the user is comfortable with.

The current available functionality allows:

  • a user to add /fika add or remove /fika remove themselves from a channel in slack.
  • a user to view the current list of subscriptions /fika list
  • automaticaly create pairings via an endpoint /index/assign-groups
  • automaticaly send direct messages to pairings via an endpoint /index/send-dms

Built With

  • NodeJS (Node version 12 as Netlify only supports Node 12)
  • MongoDB using mongoose
  • Free-tier hosting on netlify

Getting Started

To get a local copy up and running follow these steps.

Prerequistes

  • npm
npm install npm@latest -g
  • netlify
npm install netlify-cli --global

Installation

Slack Account Setup

  • Create a workspace on slack.com where you are the admin
  • Create new app using the manifest slack.manifest.yml file
  • Copy Signing Secret
    • Basic Information > App Credentials > Signing Secret
    • Setup Netlify environment variable described below
  • Copy Bot User OAuth Token
    • OAuth & Permissions > OAuth Tokens for Your Workspace > Bot User OAuth Token
    • Setup Netlify environment variable described below

MongoDB Account Setup

  • Create an account on mongodb.com
  • Create a new Database cluster
  • Create a user account with read/write permissions for readWriteAnyDatabase
  • Create network access to be open to public (Super gross, unfortunately. So create temprorary access while in development)
  • Copy the database connection string.
    • Databases > Cluster > Connect > Connect your Application
      • Choose Driver: Node.jS
      • Version: 4.0 or later
    • Setup Netlify environment variable described below

Netlify Account Setup

  • Create account on netlify.com
  • Get started with Netlify by following this guide.
  • Create environment variables for netlify:
    • MONGODB_URI: Copied from MongoDB Setup
    • SLACK_BOT_TOKEN: Copied from Slack Setup
    • SLACK_SIGNING_SECRET: Copied from Slack Setup

Local Environment

  1. Clone the repo
git clone https://github.com/github_username/repo_name.git
  1. Install NPM packages
npm install
  1. Build project
npm run build
  1. Run netlify in dev mode
netlify dev --live
  1. Update Slack command endpoint to point to generated netlify url

GitHub Actions

  • Leverage github action to trigger off scheduled task.
  • Since netlify doesn't allow us to created scheduled functions, this is a cheap way of triggering endpoints that will run our scheduled functions
  • Scheduled tasks are configured under .github/workflows
  • Tasks are currently set to run every minute, however, github changes * to a frequency they prefer which seems to be about 10 minutes

Assign Groups Scheduled Task

  • Create an environment variable ASSIGN_GROUPS_ENDPOINT pointing to the netlify endpoint for assign groups.

Send DM's Scheduled Task

  • Create an environment variable SEND_DMS_ENDPOINT pointing to the netlify endpoint for assign groups.

Configure Run tests

  • Need to update jest-settings.ts to include db connection string
  • To ignore future changes to jest-settings.ts, run
    • git update-index --skip-worktree tests/jest-settings.ts
  • To stop ignoring file
    • git update-index --no-skip-worktree tests/jest-settings.ts
export const CONFIG = {
	MONGODB_URI: "",
	SEND_DM_TO_GROUP: "false",
	OVERRIDE_USER_ID: "",
	SLACK_SIGNING_SECRET:'',
	SLACK_BOT_TOKEN:'',
};

Run tests

  • npm run test
  • npm run test -- -t 'Your test name'
  • npm run test -- /path/to/test

External Resources

fika's People

Contributors

alexchesser avatar dependabot[bot] avatar pebbz avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

pebbz simaerdem

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.