OpenWebUI-Discordbot/README.md

41 lines
1.2 KiB
Markdown
Raw Normal View History

2024-12-20 00:27:48 +00:00
# OpenWebUI-Discordbot
2024-12-20 01:19:06 +00:00
A Discord bot to communicate with an OpenWebUI instance.
A helpful guide to creating your Discord Bot's Token: https://www.writebots.com/discord-bot-token/
Before running you will need to install the required modules
```
pip install discord.py python-dotenv openai
```
This script:
Uses environment variables for secure configuration
Initializes a Discord bot with message content intents
Configures the OpenAI client to point to your OpenWebUI instance
Watches for messages that mention the bot
When mentioned, it:
Removes the mention from the message to get the actual prompt
Shows a typing indicator while processing
Sends the prompt to OpenWebUI
Handles long responses by splitting them if necessary
Posts the response back to the Discord channel
To use this bot:
Create a Discord application and bot at the Discord Developer Portal
Get your bot token and add it to the .env file
Invite the bot to your server with appropriate permissions
Set up your OpenWebUI instance and get its API endpoint
Run the script
You can mention the bot in any channel it has access to with a message like:
@YourBot What is the weather like today?
The bot will process the message and respond with the AI-generated response from your OpenWebUI instance.