Skip to content

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

License

Notifications You must be signed in to change notification settings

Lightning-Universe/Slack-Command-Bot-component

Repository files navigation

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):

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

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

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())

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages