https://github.com/debbieyuen/slack-app-mentions
Slack application to find the number count of how many times a specific word is mentioned.
https://github.com/debbieyuen/slack-app-mentions
slack-api slack-app slack-apps slack-bot
Last synced: 8 months ago
JSON representation
Slack application to find the number count of how many times a specific word is mentioned.
- Host: GitHub
- URL: https://github.com/debbieyuen/slack-app-mentions
- Owner: debbieyuen
- License: mit
- Created: 2023-10-25T23:54:45.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-26T10:39:29.000Z (almost 2 years ago)
- Last Synced: 2025-03-02T11:52:23.789Z (8 months ago)
- Topics: slack-api, slack-app, slack-apps, slack-bot
- Language: Python
- Homepage:
- Size: 354 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://api.slack.com/automation/create) 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.https://github.com/debbieyuen/slack-app-mentions/assets/31296177/561341d2-7fbb-44fb-be9e-8d0d17b4a0b3
## Requirements
* [Slack CLI](https://api.slack.com/automation/quickstart)
* [Slack Pro Workspace](https://api.slack.com/start/overview)
* Python 3.12.0
* [Python Slack SDK 3.23.0](https://slack.dev/python-slack-sdk/)
* Slack Signing Secret key
* Bot User OAuth Access Token## 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.
```bash
$ pip3 install -r requirements.txt
```Use Certifi's functions to locate installed certificate authority (CA) bundles.
```Python
import ssl as ssl_lib
import certifissl_context = ssl_lib.create_default_context(cafile=certifi.where())
```## Slack API
The [Slack Conversations API](https://api.slack.com/docs/conversations-api) provided access to channel-like things within Slack including public and private channels and messages. Using the [conversations_history](https://api.slack.com/methods/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.
## Set Up
Clone the repository
```bash
$ git clone https://github.com/debbieyuen/slack-app-mentions.git
```Install Slack CLI (Mac)
```bash
# 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](https://api.slack.com/apps). In your terminal, add your token to your environment variables.
```bash
$ export SLACK_BOT_TOKEN='xoxb-XXXXXXXXXXXX-xxxxxxxxxxxx-XXXXXXXXXXXXXXXXXXXXXXXX'
```Retrieve your **Slack Signing Secret** key for your app from the [app management page](https://api.slack.com/apps). In your terminal, run the following command.
```bash
$ export SLACK_SIGNING_SECRET='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
```Run the python file
```bash
$ python3 bot.py
```On the [app management page](https://api.slack.com/apps), install the DebBot app in your workspace. Then, in Slack add the DeBot app to the `#general` channel.
## Credits and References
* [Python Slack SDK Documentation](https://github.com/slackapi/python-slack-sdk)
* @karishay's [PythOnBoardingBot](https://github.com/slackapi/python-slack-sdk/tree/main/tutorial) tutorial
* [The New Slack Platform](https://www.youtube.com/playlist?list=PLWlXaxtQ7fUYi7HPZMi0fUU7YbYZXemsp) YouTube series
* [Slack: Retrieving Messages](https://api.slack.com/messaging/retrieving)
* [Slack: Conversations API](https://api.slack.com/docs/conversations-api)
* [Slack: Using the Slack Web API](https://api.slack.com/web)