Giter VIP home page Giter VIP logo

bot's Introduction

๐Ÿค– devICT bot ๐Ÿค–

A slack bot powered by Slack webhook events.

Overview

This is not using any of the Slack platform stuff. Trying to keep it simple by simply receiving webhook events from Slack and responding to those events however we want.

  • Runs as an API service listening on a /slack/event endpoint for webhook events from Slack.
    • Deployed to Deno Deploy
  • Commands are implemented as handlers that are executed if the message from the event matches some defined criteria.
  • Responses to the events are sent as separate HTTP requests, not as responses to the incoming webhooks.
    • We're using the @slack/web-api package, which is a thin wrapper over Slack's HTTP API.

Contributing

This is a great project to contribute to as a member of the devICT community!

Local dev

This project runs on TypeScript with Deno.

Setup

  • Install deno with brew install deno, or several other methods
  • Copy .env.example to .env
  • Plug your SLACK_TOKEN in to .env (reach out to @seth for this)
  • Run deno task cache to download dependencies

Running the service

  • deno task start

Testing commands locally

There is a separate Slack app for development (@bot (test)) that can be used. Reach out to @seth in Slack for the SLACK_TOKEN.

Simulate events from Slack hitting your local server with the bin/simulate-message util.

$ bin/simulate-message.ts "@bot ping"

You won't see the simulated message in Slack, but the response will show up there from @bot (test).

Slack App

This bot is installed in the devICT work space as a Slack app called bot.

  • The OAuth & Permissions page contains the SLACK_TOKEN needed to power the bot.
    • The following scopes must be added: app_mentions:read, chat:write
  • The event receiving endpoint must be added on the Event Subscriptions page.
    • Events to subscribe to: app_mention

Slack Events

A list of all the events can be seen here.

The events the bot responds to are defined in the events.ts module. Typebox schemas are defined for the events we respond to.

Note: If we want to respond to new event types, we will need to add them in the Slack app console before Slack will start sending them.

Deployment

Bot is deployed on Deno Deploy. The Slack App points to the /slack/event endpoint of the deployed bot API (this repo).

bot's People

Contributors

sethetter avatar

Stargazers

 avatar

Watchers

Sandip Southekal avatar  avatar Christen Lofland avatar

Forkers

justincockrell1

bot's Issues

@bot help

List the available commands.

Thoughts on implementation

Each command should define name and helpText properties for displaying.

This should probably be a top level thing defined in server.ts instead of a separate command.

Questions

  • How can the matcher functions be shown in the help text? Or should help text just describe what matches and what doesn't?

@bot new job <url>

A command that takes a URL to a job posting and turns it into a job listing on the devICT job board.

This useTool util would make it fairly easy to write a tool that can pull the necessary data from the page!

I don't think the job board exposes an API endpoint for this, so that would be needed as well.

Improve and document local dev experience

  • Utility for simulating event callback requests from Slack
  • Documentation

For simulating event calls from Slack locally..

  • ./simulate-app-mention.ts "@bot some message"
  • The util sends a fake app_mention event payload to the local server.
    • Hardcodes the channel to respond in to #bot-testing.
    • Optionally a message thread ID can be provided to the util to test threaded replies.
  • The actual response is sent to the #bot-testing slack channel, or the provided thread.

Only pre req for someone to use this locally is a SLACK_TOKEN that allows posting as the @bot (test) app.

@bot question

Chooses from a list of questions to ask as conversation starters.

Respond in thread

For some commands, especially any that may output a large amount of text, responding to the message in thread, instead of in the main channel might be a better experience.

  • Create a function that determines where to send the response based on the event so it can be reused.
    • If the message came from a thread, respond in that thread.
    • If the message did not come from a thread, respond in the thread for that message.
  • Apply this to the ping and jobs commands.

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.