Skip to content

Latest commit

 

History

History
46 lines (27 loc) · 1.94 KB

README.md

File metadata and controls

46 lines (27 loc) · 1.94 KB

Slack Channel Bot

Slack Channel Bot is a C# console application that listens for messages in a specific Slack channel and responds to them based on certain keywords. It uses the RestSharp library for making API requests to the Slack API.

Setup

  1. Create a new bot(app) in your Slack workspace and generate a bot token for it. And you must add the necessary bot scopes.
  2. Set the slackBotToken, slackChannelIDForListen, and slackBotUserID variables in the Program.cs file to the appropriate values for your Slack bot and channel.
  3. Run the application.

Usage

The SlackChannelBot listens for incoming messages in the specified Slack channel and responds to them based on certain keywords.

Available Commands

  • -help: Shows a list of available commands.

Example Usage

User: Hello!

Bot:

image

Methods

  • Main(string[] args): The entry point of the application. Initializes the application and starts listening for incoming messages.
  • GetLastMessage(): Retrieves the timestamp of the last message received in the specified Slack channel.
  • ListenForMessages(): Listens for incoming messages in the specified Slack channel and responds to them based on certain keywords.
  • SendMessage(string userId, string text): Sends a message to the specified user in the specified Slack channel.

Variables

  • slackBotToken: The bot token for authentication.
  • lastMessageTimestamp: A variable to store the timestamp of the last message received.
  • slackChannelIDForListen: The ID of the Slack channel where the bot will listen for incoming messages.
  • slackBotUserID: The ID of the Slack bot user.
  • slackBaseURL: The base URL for the Slack API.

License

MIT