Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lightning-universe/slack-command-bot-component

With this component you can create a Slack bot and enable interactivity with the Slash Commands.
https://github.com/lightning-universe/slack-command-bot-component

Last synced: 7 days ago
JSON representation

With this component you can create a Slack bot and enable interactivity with the Slash Commands.

Awesome Lists containing this project

README

        

# slack_command_bot component

With this app you can create a Slack bot and enable interactivity with the Slash Commands.
It can recieve slash commands and send message or files with the Slack client API.

## How to Run Slack Command Bot

First, install slack_command_bot (warning: this component has not been officially approved on the lightning gallery):

```bash
lightning install component git+https://github.com/Lightning-AI/LAI-slack-messenger.git@main
```

Once the app is installed, use it in an app:

```python
from slack_command_bot import SlackCommandBot
import lightning as L
import slack
from flask import request

class DemoSlackCommandBot(SlackCommandBot):
def handle_command(self):
"""Customize this method the way you want your bot to interact with the prompt."""
client = slack.WebClient(token=self.bot_token)
data: dict = request.form
channel_id = data["channel_id"]

client.chat_postMessage(text="testing post msg", channel=channel_id)
return "Hey there! command was received successfully", 200

class LitApp(L.LightningFlow):
def __init__(self) -> None:
super().__init__()
self.slack_bot = DemoSlackCommandBot(command="/LAIcommand")

def run(self):
print(
"this is a simple Lightning app to verify your component is working as expected"
)
self.slack_bot.run()

app = L.LightningApp(LitApp())
```