Git Product home page Git Product logo

slack-app-mentions's Introduction

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

slack-app-mentions's People

Contributors

debbieyuen avatar

Watchers

 avatar

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.