GithubHelp home page GithubHelp logo

memgraph / slack-influence-bot Goto Github PK

View Code? Open in Web Editor NEW
23.0 6.0 0.0 98 KB

A slack bot that helps you understand and influence your slack community

Home Page: https://github.com/memgraph/slack-influence-bot

License: MIT License

Python 98.10% Dockerfile 1.90%
python slack memgraph kafka graph-algorithms slack-bot slack-api

slack-influence-bot's Introduction

๐Ÿ’ฌ Slack Influence Bot ๐Ÿ”

license build

Follow @memgraphdb

reddit-network-explorer

Are you curious about the affinity of the people in your organization? Do you ever wonder what kind of conversation draws the most attention in your community or the most frequently used emojis? Slack Influencer allows you to introspect your Slack community providing you with valuable insights and analytics of its members.

At its core, Slack Influencer uses Memgraph to leverage the power of knowledge graphs while scraping slack messages in real-time. The data produced is then stored in Memgraph and consumed by your soon-to-be favorite Slack bot plugin. The bot acts as an interactive tool in that the user queries for analytics.

โš™๏ธ Requirements

๐Ÿ–ฅ๏ธ Quick start

Setup Slack bot application

Make sure to set up a Slack bot application where you will need two tokens for the application to work

  • Application token: xapp-... (step 2 below)
  • Bot token: xoxb-... (step 5 below)

Follow the steps below to create the bot, set up scopes, and get the tokens:

  1. Create a Slack app if you don't already have one, or select an existing app you've created.
  2. Under Basic Information > App-Level Tokens create a new App Token with a scope connections:write.
  3. Under Socket Mode make sure to enable the socket mode.
  4. Under Slash Commands create the following commands:
    • Name: /influence
    • Short description: Influence the community
    • Usage hint: [help | me | channel | message]
    • Escape channels, users, and links sent to your app: Checked!
  5. Under *OAuth & Permissions generate a Bot User OAuth Token and add the following scopes to "Bot Token Scopes":
    • app_mentions:read
    • channels:history, channels:read
    • groups:history, groups:read
    • users:read, users.profile:read
    • chat:write
    • commands
    • reactions:read
  6. Under Event Subscriptions make sure to enable Events and to select the following events for "Subscribe to bot events":
    • message.channels
    • message.groups
    • reaction_added
    • reaction_removed
    • member_joined_channel
  7. Add the bot to all the public channels that you want to handle with the project
  8. Once you have two tokens, feel free to save them locally in the .env file in the following format:
export SLACK_BOT_TOKEN=xoxb-...
export SLACK_APP_TOKEN=xapp-...

Start the platform

Environment

Before starting a platform that consists of the Slack bot application, Kafka, Zookeeper, and Memgraph, make sure to have environment variables SLACK_BOT_TOKEN and SLACK_APP_TOKEN defined.

You can check if the environment variables are set by calling the following command:

docker-compose config

In the output, you should see the values of your tokens in the following two lines:

...
      - SLACK_BOT_TOKEN=xoxb-...
      - SLACK_APP_TOKEN=xapp-...
...

Build and run

Run the platform with the following command:

docker-compose up

Tools

Connect to Memgraph

Download Memgraph Lab and connect to running Memgraph:

Username: <Empty>
Password: <Empty>
Endpoint: localhost 7687
Encrypted: Off

Connect to Kafka

If you wish the check the state of Kafka and the topic where slack events have been produced to, run the following command:

docker run -it -p 9000:9000 -e KAFKA_BROKERCONNECT=localhost:9092 obsidiandynamics/kafdrop

Note: If you are running Docker on Mac or Windows, the value of KAFKA_BROKERCONNECT should be host.docker.internal:9093.

Open up the internet browser and to the address localhost:9000.

Load the historical data

When you start the platform, you will start to receive events from that point on. If you wish to include messages and reactions from public/private channels where the bot is a member, you can use the utility functions to load up the last N messages (including reactions and thread replies) from channels:

# Get 100 messages (with threads and reactions) from public/private channels where
# bot is member of and forward it to the local file `events.json`
python main.py history --message-count=100 > history-messages.json

# Or even do that at the application startup
python3 main.py --history-message-count=100

# If you wanna see all available commands, just run
python3 main.py --help

# For every slack historical event, forward it to the Kafka so Memgraph can fetch it
# and update the graph model
cat events.json | python3 scripts/kafka_json_producer.py slack-events

โ” Find out more about Memgraph

Memgraph makes creating real-time streaming graph applications accessible to every developer. Spin up an instance, consume data directly from Kafka, and build on top of everything from super-fast graph queries to PageRank and Community Detection.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):


Toni Lastre

Kostas Kyrimis

Nikolina Motocic

This project follows the all-contributors specification. Contributions of any kind welcome!

slack-influence-bot's People

Contributors

antejavor avatar g-despot avatar kostasrim avatar nmotocic avatar tonilastre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  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.