Code Monkey home page Code Monkey logo

redashbot's Introduction

Slack Bot for Redash V2

Redashbot V2 is a open-source slack bot for Redash.

(This project was forked from hakobera/redashbot, but it is not maintained anymore. I have rewritten almost all of the code and published as v2.)

Features

  • Visualization(Chart) screenshot
  • Dashboard screenshot
  • Table result (NOT SCREENSHOT)
  • Docker deployment
  • Serverless deployment
  • HTTP-based New Slack app (non-RTM style)
  • Open source!

screenshot.png

Usage

  • Visualization
    • @botname <Query URL>#<Viz ID>
      • e.g. @redash https://your-redash-server.example.com/queries/1#2
  • Dashboard
    • @botname <Dashboard URL>
      • e.g. @redash https://your-redash-server.example.com/dashboards/dashboard-name
  • Table
    • @botname <Query URL>#table
      • e.g. @redash https://your-redash-server.example.com/queries/1#table

Setup

Create a Slack app and set environment variables SLACK_BOT_TOKEN and SLACK_SIGNING_SECRET.

The Official Document.

On Event Subscription page, Request URL will be https://<your-domain>/slack/events.

Then, npm start or docker run yamitzky/redashbot:main to start. When you use Docker, do not forget to pass environment variable via -e or .env file.

Slash Command (Optional)

You can use redashbot with /redash-capture [URL].

On Slash Command page of your app, click [Create New Command] and submit. Command must be /redash-capture and Request URL will be https://<your-domain>/slack/events.

Workflow Steps (Optional)

You can use redashbot as a Workflow step.

On Interactivity & Shortcuts page of your app, enable Interactivity. Request URL will be https://<your-domain>/slack/events.

Then, move to Workflow Steps page, and click [Add Step] and submit. Callback ID must be redash_capture.

Environment variables

SLACK_BOT_TOKEN (required)

Slack's bot token.

SLACK_SIGNING_SECRET (required)

Slack's sigining secret.

REDASH_HOST and REDASH_API_KEY (optional)

Redash's URL and its API Key.

REDASH_HOST_ALIAS (optional)

Redash' URL accessible from the bot.

REDASH_HOSTS_AND_API_KEYS (optional)

If you want to use multiple Redash at once, specify this variable like below

REDASH_HOSTS_AND_API_KEYS="http://redash1.example.com;TOKEN1,http://redash2.example.com;TOKEN2"

or if you need to specify REDASH_HOST_ALIAS for each Redash, like below

REDASH_HOSTS_AND_API_KEYS="http://redash1.example.com;http://redash1-alias.example.com;TOKEN1,http://redash2.example.com;TOKEN2"

SLEEP_TIME (optional)

Milliseconds to wait loading finished before capturing.

BROWSER (optional and experimental)

chromium, firefox or webkit. default is chromium

How to develop

Clone this repository, then

$ npm install
$ export REDASH_HOST=https://your-redash-server.example.com
$ export REDASH_API_KEY=your-redash-api-key
$ export SLACK_BOT_TOKEN=your-slack-bot-token
$ node index.js

Deploy

Redashbot is just a node program.

npm start

Docker

Docker image is provided. Currently, latest tag is used for v1(old), then you must use 2.0.0 or something like that.

docker run -it --rm -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e REDASH_HOSTS_AND_API_KEYS=$REDASH_HOSTS_AND_API_KEYS -p 3000:3000 yamitzky/redashbot:2.0.0

docker-compose is also provided.

docker-compose up

Heroku (NOT TESTED!!!!!!!!)

You can easy to deploy redashbot to Heroku, just click following button.

Deploy

redashbot's People

Contributors

yamitzky avatar hakobera avatar k-kawa avatar yuya-takeyama avatar doiken avatar kenchan avatar

Stargazers

piggy.wang avatar Yodai Kishimoto avatar Masakazu Ohtsuka avatar kaho mukaiya avatar Ryo S. avatar Takumi Abe avatar Nikita K avatar Kentaro Ueda avatar NaokiMatsumoto avatar Yoshiyuki Shima avatar  avatar Goki Mori avatar Kazato Sugimoto avatar Kenichi Saito avatar Toru Nishiyama avatar Takahiro Mishiro avatar Taku Okawa avatar nagi avatar Riku Takahashi avatar Keiichi Yamada avatar  avatar nakano-shingo avatar Yuu Ito avatar Takashi Abe avatar nakamura.teturou avatar meijin avatar Suguru Ohki avatar keitosugiyama avatar Yattan avatar Jeremy avatar  avatar Baris Ozgen avatar gomesuit avatar Masumi Kawasaki avatar Kei IWASAKI avatar Takuya Mukohira avatar Shitij Goyal avatar Naohisa avatar Takuya Arita avatar Bennett Gebken avatar Yuichi Goto avatar Koya Suzuki avatar kazuki matsumoto avatar Tatsuro Inoue avatar amato avatar Yoshihiro Saito avatar hodaka.umehara avatar Sadayoshi Tada avatar Makoto Tajitsu avatar yowatari avatar Bryan Yang avatar Masaki Ogawa avatar  avatar Mike Nason avatar misu avatar  avatar yohei takahashi avatar  avatar Kenjo Yasui avatar

Watchers

 avatar James Cloos avatar Riku Takahashi avatar

redashbot's Issues

Docker start command

Please change dokcer commad from

docker run -it --rm -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e REDASH_HOSTS_AND_API_KEYS=$REDASH_HOSTS_AND_API_KEYS -p 3000:3000 yamitzky/redashbot:2.0.0

to

docker run -it --rm -e SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN -e SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET -e REDASH_HOST=$REDASH_HOST -e REDASH_API_KEY=$REDASH_API_KEY -e SLEEP_TIME=$SLEEP_TIME -p 3000:3000 yamitzky/redashbot:latest

Workaround for files.upload API deprecation for newly-created Slack apps after May 16, 2024

https://api.slack.com/changelog/2024-04-a-better-way-to-upload-files-is-here-to-stay

When does this happen?

There are two keys dates to keep in mind:

  1. As of May 16, 2024, newly-created Slack apps are no longer able to access the files.upload API. All new apps must use the new methods.
  2. On March 11, 2025, the files.upload API will be sunset and no longer available. All apps, new and old, must use the new methods by this date.

Currently, newly created applications are failing to upload screenshots. According to the official documentation, it is recommended to use files.uploadV2 instead of files.upload.
I was able to resolve this issue by making the following change in handlers.ts:

- client.files.upload({
+ client.files.uploadV2({

This change allows the application to successfully upload screenshots using the updated files.uploadV2 API method, which is the recommended approach for newly created Slack apps after the deprecation of files.upload.
By sharing this workaround, I hope it helps others who may be facing similar issues with file uploads in their newly created Slack apps.

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.