/stackoverflow-slack-bot

Track a tag on StackOverflow and push to Slack

Primary LanguageJavaScriptMIT LicenseMIT

StackOverflow Slack Integration

Build Status Docker Build Status

This is a basic script to keep track a tag on StackOverflow and push accurate links to Slack.

slackoverbot

How to use

  • Make sure Node is installed.

  • Run npm install.

  • Add your configuration to config.json

  • Let a cron-job run npm run start every 15 minutes (StackOverflow quota is 300 requests by day)

config.json
{
  "tags": "tag1;tag2",
  "so": {
    "apiBaseURL": "https://api.stackexchange.com/2.2",
    "dayBack": 1,
    "hourBack": 0,
    "minuteBack": 0
  },
  "slack": {
    "apiBaseUrl": "https://[your_team_name].slack.com/api/",
    "token": "[your_token]",
    "channel": "#random",
    "botName": "[your_bot_name]",
    "botIcon": "[your_bot_icon]",
    "icons": {
      "newActivity": ":trackball:",
      "topic": ":speaking_head_in_silhouette:",
      "askedQuestion": ":speech_balloon:",
      "revisedQuestion": ":pencil:",
      "revisedAnswer": ":pencil:",
      "answerAccepted": ":ok_hand:",
      "postedAnswer": ":left_speech_bubble:",
      "comment": ":grey_question:"
    }
  },
  "lastEndFileName": "lastend",
  "dryRun": false
}
tags

name of the tags to track (separate by ;),

so.apiBaseURL

URL of the StackOverflow API.

so.minuteBack

number of minutes previous now, use for create the first query.

so.hourBack

number of hours previous now, use for create the first query.

so.dayBack

number of days previous now, use for create the first query.

slack.apiBaseUrl

URL of Slack API.

slack.token

Slack token, only for dev purpose. DON’T USE IN PRODUCTION.

slack.channel

Name of the channel to publish. (must start with #)

slack.botName

your bot account name.

slack.botIcon

your bot emoji icon. (can be blank.)

slack.icons.xxx

emoji for each situation. (can be blank.)

lastEndFileName

name of file use for store the last query date.

dryRun

if true, display the Slack payload without send it.

In production, use environment variable to set your Slack token (SLACK_API_TOKEN).

Thanks to @cwi-swat for inspiration.