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.
- Create a new bot(app) in your Slack workspace and generate a bot token for it. And you must add the necessary bot scopes.
- Set the
slackBotToken
,slackChannelIDForListen
, andslackBotUserID
variables in theProgram.cs
file to the appropriate values for your Slack bot and channel. - Run the application.
The SlackChannelBot listens for incoming messages in the specified Slack channel and responds to them based on certain keywords.
-help
: Shows a list of available commands.
User: Hello!
Bot:
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.
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.