Skip to content

Slack application to find the number count of how many times a specific word is mentioned.

License

Notifications You must be signed in to change notification settings

debbieyuen/slack-app-mentions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

Slack App: Component Mention Counts 🔥

A Slack App feature that helps users determine how often a component/element/word was mentioned within Slack messages. The feature provides the user with a number count of the times a specific component is mentioned and referenced.

The project starts off by creating a new Slack App and workspace to build my app. I chose to create a new workspace! Within the application, scopes were used to give the new app permission to do things. Under the OAuth & Permissions tab in the sidebar, add scopes to the app. The scopes that will be necessary include:

  • channels:read: This scope allows the app to retrieve a list of all the public channels in a workspace in order to pick one to retrieve a message from.
  • channels:history: This scope lets the app view all the messages within any public channel in a workspace.
Screen.Recording.2023-10-26.at.2.00.12.AM.mov

Requirements

Python-Slack

In the root directory, create a requirements.txt file and add the following contents to the file.

slack_sdk>=3.0
slack_bolt>=1.6.1
certifi

Install the dependencies by running the following command from terminal.

$ pip3 install -r requirements.txt

Use Certifi's functions to locate installed certificate authority (CA) bundles.

import ssl as ssl_lib
import certifi

ssl_context = ssl_lib.create_default_context(cafile=certifi.where())

Slack API

The Slack Conversations API provided access to channel-like things within Slack including public and private channels and messages. Using the conversations_history method, I was able to find all the messages. From there, the text was converted into strings and stored in an array with single-word strings.

Screenshot 2023-10-26 at 3 31 02 AM

Set Up

Clone the repository

$ git clone https://github.com/debbieyuen/slack-app-mentions.git

Install Slack CLI (Mac)

# Run the automated installer from your terminal window:
$ curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash

# Authorize the CLI in your workspace with the following command:
$ slack login

# Input an entry for a paid workspace
$ slack auth list

Retrieve your Bot User OAuth Access Token for your app from the app management page. In your terminal, add your token to your environment variables.

$ export SLACK_BOT_TOKEN='xoxb-XXXXXXXXXXXX-xxxxxxxxxxxx-XXXXXXXXXXXXXXXXXXXXXXXX'
Screenshot 2023-10-26 at 2 57 37 AM

Retrieve your Slack Signing Secret key for your app from the app management page. In your terminal, run the following command.

$ export SLACK_SIGNING_SECRET='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
Screenshot 2023-10-26 at 3 01 21 AM

Run the python file

$ python3 bot.py

On the app management page, install the DebBot app in your workspace. Then, in Slack add the DeBot app to the #general channel.

Screenshot 2023-10-26 at 3 06 19 AM

Credits and References

About

Slack application to find the number count of how many times a specific word is mentioned.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published