Skip to content
forked from karlunho/keanubot

Let the most excellent Keanu improve your group chat conversations.

License

Notifications You must be signed in to change notification settings

bretmcg/keanubot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KeanuBot

Let the most excellent Keanu Reeves improve your Slack conversations.

Excellent

Overview

The bot consists of three parts:

1. Event notification Cloud Function

A Google Cloud Function that Slack calls whenever a given slack event occurs (e.g. message posted to chat). This function then invokes Dialogflow to do Natural Language Processing.

2. Dialogflow

Dialogflow takes raw text and converts it into intents, actions, and entities. It can either respond directly with messages, or hand off to a fulfillment webhook for additional processing.

3. Fulfillment webhook Cloud Function

After Dialogflow has validated and converted a chat message into explicit actions and entities, it can call an HTTP webhook (Google Cloud Function) so we we can apply our business logic to those entities. This generates a response and sends it back to Dialogflow, which in turn calls the original Cloud Function to post a message to Slack.

Setup: Slack, Dialogflow, and Google Cloud Platform

  1. Create a Slack App and install it on your team.

  2. Create a Google Cloud Platform project.

  3. Create a Dialogflow project.

Setup: Google Cloud Platform

  1. Clone this repository to your local workstation: $ git clone https://github.com/bretmcg/keanubot

  2. Using your Slack and Dialogflow credentials, copy dot.env.sample to .env using $ cp functions/dot.env.sample functions/.env and add the API key correct values.

    Config Variables - .env

    Name Description
    APIAI_TOKEN The Dialogflow client access token
    SLACK_BOT_TOKEN The Slack Bot OAuth token. Slack Developers Console > OAuth & Permissions > Bot User OAuth Access Token
    SLACK_VERIFICATION_TOKEN The Slack verification token. Slack Developer's Console > Basic Information > Verification Token
  3. Install the gcloud command line tool to manage your Google Cloud Platform project.

  4. Deploy the event notification function keanubot to Cloud Functions:

cd functions/
gcloud beta functions deploy keanubot --trigger-http
  1. Add the keanubot function URL to the Slack event subscription page. It should be in the format https://REGION-PROJECT.cloudfunctions.net/keanubot.
  2. Deploy the Dialogflow fulfillment webhook.
gcloud beta functions deploy apiaifulfillment --stage-bucket <YOUR_CLOUD_STORAGE_BUCKET> --trigger-http
  1. Add the apiaifulfillment function URL to the Dialogflow Fulfillment page, and make sure Webhook is Enabled.

  2. Invite your bot into a channel and watch it respond to you!

Local development and testing

  1. $ cd functions/
  2. $ npm install
  3. Add security token values to .env as before.
  4. $ node server.js
  5. In a new terminal window:
    1. Download ngrok and unzip into the functions/ directory.
    2. From functions/ run $ ngrok http 3005
  6. Slack event subscription: add the local keanubot URL to the Slack app page. It should be in the format https://2f75d6e9.ngrok.io/keanubot.
  7. Dialogflow fulfillment URL: Add the local apiaifulfillment URL to the Dialogflow Fulfillment page, and make sure Webhook is Enabled. The URL should be in the format https://2f75d6e9.ngrok.io/apiaifulfillment

About

Let the most excellent Keanu improve your group chat conversations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%