Skip to content

Slack bot user who automatically responds with an ephemeral message whenever you use one of the 'bad words' and suggests another word to use instead

Notifications You must be signed in to change notification settings

hopemiller14/techlanguagebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tech Language Bot

Slack bot user who automatically responds with an ephemeral message whenever you use one of the 'bad words' and suggests another word to use instead

Local Dev

First time

  1. cp .envrc.example .envrc
  2. Paste your app's workspace URL into .envrc.
  3. Get an OAuth access token for your bot from Slack (see here), and paste it into .envrc.
    1. Give your bot the following Bot Token Scopes:
      • channels:history
      • channels:read
      • chat:write
      • groups:history
      • groups:read
      • users:read
  4. Get the signing secret for your bot from Slack (see here), and paste it into .envrc.
  5. Create a username for your bot in Slack, and paste it into into .envrc.
  6. terminal window 1:
    1. yarn
    2. yarn start-ngrok
    3. Copy the https Forwarding URL from the ngrok output; e.g. https://98fbc0c341db.ngrok.io
    4. In Slack go to your bot's Event Subscriptions page. In Request URL paste in the ngrok URL + /slack/events.
  7. terminal window 2:
    1. yarn verify
    2. On the Event Subscriptions page in Slack and wait until your app is successfully verified (you might have to click Retry).
    3. On the Event Subscriptions page, Subscribe to the following Bot Events: * message.channels * message.groups
    4. Click Save Changes at the bottom of the page.
    5. Once your app is successfully verified, you can kill the process in window 2.
  8. Create a new slash command for your app in Slack (see here) with the following settings:
    • Command: /getbadwordlist
    • Request URL: ngrok URL + /slack/getbadwordlist
    • Description: Gets the list of bad words that Tech Language Bot currently knows
    1. You might need to reinstall the app to your workspace again after this step.

Every time

  1. terminal window 1:
    1. yarn start
  2. in terminal window 2:
    1. yarn start-ngrok
    2. Copy the https Forwarding URL from the ngrok output; e.g. https://98fbc0c341db.ngrok.io
    3. In Slack go to your bot's Event Subscriptions page. In Request URL paste in the ngrok URL + /slack/events.
    4. Wait until your app is successfully verified, then click Save Changes.

Run the tests

yarn test

Questions

ex: bad words are "cat", "dog"

  • What happens when user uses multiple words in same message? "It's raining cats and dogs!"
    • Send one slack message per bad word.
  • What about when using multiple of the same word in the same message? "Here a cat. There a cat. Everywhere a cat. Cat."
    • Do not send multiple messages for multiple uses of the same word in the same message.
  • What about substrings? "Do you want to go play catch?"
    • Bot is triggered. (Hopefully this will be a small price to pay given our list of bad words.)
  • What about totally appropriate context? "We're no longer going to say the words 'cat' and 'dog' because they are bad."
    • Bot is triggered.
  • Editing messages:
    • What happens when a user posts a harmless message, then they edit it and add a bad word?
      • Nothing happens on initial post. Bot is triggered on edit.
    • What happens when a user posts a message with a bad word, then they edit it and remove the bad word?
      • Bot is triggered on initial post. Nothing happens on edit.
    • What happens when a user posts a message with a bad word, then they edit it but leave the bad word unchanged?
      • Bot is triggered on initial post and again on edit.
    • What happens when a user posts a message with a bad word, then they edit it and add a different bad word?
      • Bot is triggered on initial post and again on edit.
  • Deleting messages:
    • What happens when a user posts a harmless message, then they delete it?
      • Nothing.
    • What happens when a user posts a harmless message, then another user deletes it?
      • Nothing.
    • What happens when a user posts a message with a bad word, then they delete it?
      • Bot is triggered for initial posting of message. Nothing happens on delete.
    • What happens when a user posts a message with a bad word, then another user deletes it?
      • Bot is triggered for initial posting of message. Nothing happens on delete.
  • Sharing messages:
    • What happens when a user shares a harmless message with a channel and writes no message text?
      • Nothing.
    • What happens when a user shares a message with a bad word with a channel and writes no message text?
      • Bot is triggered on initial posting of message. ...Bot is triggered again on sharing? and sends a message to... both users? only the sharing user?
        • Current behavior: Bot is triggered on initial post. Nothing happens on share.
    • What happens when a user shares a harmless message with a channel and writes harmless message text?
      • Nothing.
    • What happens when a user shares a message with a bad word with a channel and writes harmless message text?
      • Bot is triggered on initial posting of message. ...Bot is triggered again on sharing? and sends a message to... both users? only the sharing user?
        • Current behavior: Bot is triggered on initial post. Nothing happens on share.
    • What happens when a user shares a harmless message with a channel and writes a bad word in the message text?
      • Nothing happens on initial post. Bot is triggered on sharing and sends message to sharing user.
    • What happens when a user shares a message with a bad word with a channel and writes a bad word in the message text?
      • Bot is triggered on initial post. Bot is triggered on sharing and sends message to sharing user.
  • Copying links to messages:
    • What happens when a user copies a link to a harmless message in a public channel and posts it in another channel? Nothing.
    • What happens when a user copies a link to a message with a bad word in a public channel and posts it in another channel?
      • Bot is triggered on initial posting of message. ...Bot is triggered again on posting copied message link? and sends a message to... both users? only the copying user?
        • Current behavior: Bot is triggered on initial post. Nothing happens on posting copied link.
    • What happens when a user copies a link to a harmless message in a private channel and posts it in another channel? Nothing.
    • What happens when a user copies a link to a message with a bad word in a private channel and posts it in another channel?
      • Bot is triggered on initial posting of message. ...Bot is triggered again on posting copied message link? and sends a message to... both users? only the copying user?
        • Current behavior: Bot is triggered on initial post. Nothing happens on posting copied link.
  • Threads:
    • What happens when a user posts or edits a harmless message in a channel?
      • Nothing.
    • What happens when a user posts or edits a bad message in a channel?
      • Bot replies in channel.
    • What happens when a user posts or edits a harmless message in a thread?
      • Nothing.
    • What happens when a user posts or edits a bad message in a thread?
      • Bot replies in thread.
    • What happens when a user shares or copies/pastes a link to a harmless message in a channel?
      • Nothing.
    • What happens when a user shares or copies/pastes a link to a bad message in a channel?
      • Bot replies to message sharer in channel.
    • What happens when a user shares or copies/pastes a link to a harmless message in a thread?
      • Nothing.
    • What happens when a user shares or copies/pastes a link to a bad message in a thread?
      • Bot replies to message sharer in thread.

TODO

  • filter out messages from all bot users? or maybe instead broadcast response to entire channel since only the bot would see it
  • dockerize it! including a mysql service for limited DB tracking below
  • add logging
  • future idea: keep track of # of occurrences of each bad word
    • break down by bot users vs real users?
    • keep track in a DB
    • user type: [bot | real], ts, word
    • could create a new endpt for querying
  • future idea: make words configurable by channel?
    • maybe make slack bot interactable?
  • how to handle "resources" and "worker"? impossible to distinguish between person vs machine
  • make /getbadwordlist work in threads

Resources

About

Slack bot user who automatically responds with an ephemeral message whenever you use one of the 'bad words' and suggests another word to use instead

Resources

Stars

Watchers

Forks