Deploy this function on flows.network, and you will get a Discord bot that uses ChatGPT to respond to every question in your Discord DM.
- You will need to bring your own OpenAI API key. If you do not already have one, sign up here.
- You also need a bot token to access the Discord API. Please refer to How to create a Discord chat bot to save the Discord API Token and invite the bot to your server. You can see the bot is offline now. But don't worry! After you finish all the steps, the bot will be online.
- Create a bot from a template
- Add your ChatGPT API key
- Add the Discord bot token
Here you can see three variables. You can customize the system_prompt
variable to prompt ChatGPT.
Click on the Create and Build button.
You will now set up Discord integration. Enter your Discord token here. Please refer to How to create a Discord chat bot.
Click on Continue.
You will now set up OpenAI integration. Click on Connect, and enter your key.
Close the tab and go back to the flow.network page once you are done. Click on Deploy button.
When the status of the flow is ready and running, you can go back to your Discord server and check out the status of the bot you just invited.
Now you can see the bot on the right online
contact list. DM the bot or @the bot in a channel, the bot will answer your questions.
If you want to build locally, make sure you have installed Rust and added wasm32-wasi
traget.
cargo build --target wasm32-wasi --release