how to add chatgpt to the discord

how to add chatgpt to discord

how to add chatgpt to discord server? yeah, that’s the question in every tech geek’s mind popping up right after so much hype about the popular ChatBot which is CHATGPT. this post should clear things up and will let you know how you can add ChatBOT (CHATGPT) to Your discord let’s get started –

how to add chatgpt to discord

Chat GPT can be added to Discord and in this Article I’m going to show you how you can do this and there’s lots of opportunity here I’ve already had so much fun interacting with it myself either on my computer or even just on my mobile phone typing in prompts whenever I want as well as my community members having a lot of fun just chatting to it I’ll structure this article in three parts first we’ll set up node.js to interact with Discord and openai and it’s API second we’ll set up Discord with the bot so that it can engage with community members and third will connect the two – I built out this entire chatbot so you guys can download and use at any points out then you can do so at the link in the description below and we’ve got said and done let’s begin Discord chatbot then I’m going to initialize a new project by running mpm in it – why this will create the package.json here I’ve got all my modules installed or at least I will second I’m going to install three packages I’m going to run npm install I’m going to install discord.js openai and Dot Envy next I’ll create the file.env as well as index.js which is where our server and configuration will lie finally I’ll check that I’m running the latest node version -now back to the point – how to add chatgpt to the discord

which should be version 18 as well as my NPN version which currently is version 8.8 now assuming you have Discord installed go to the server section and create a new server for yourself or for your community I’m going to call This Server the chat GPT Discord chatbot which is essentially what we’re making once this is done I’m going to open up Chrome and head to a special URL called discord.com/applications I’m going to create a new app application this application I’m going to give the name select to apply the terms and conditions this new application now can be customized the first thing I want to do is update the Avatar I want an avatar here that represent the chat GPT –

Steps to Adding & Configure ChatBot

I want to create a bot for this application going to select bot on the left hand side and going to select it to add a bot on the right side when WE add a bot WE do need to give it a name and you can’t have the word Discord inside of your bot name so WE do need to go back in my general information and change the name for this application to remove that word Discord once WE’ve done that WE can go back and save my changes and then select to create the board once more WE’ve successfully created my butt WE do need the security token in order to use it properly WE’m going to reset this token and capture the new token second start using it what WE’ll do is reset the token here and then WE’m going to do two Factor authentication and then once WE’ve done that WE can grab this token and WE can paste it inside of vs code so WE’m going to open up the VS code project on the dot Envy file and WE’m going to create a new variable here this variable will be Discord on the score token WE’m going to Pace the value here for that –

WE also want to create a few other placeholder values here the open AI organization and the openai key for the API key with that done WE want to scroll down to privileges for the Gateway intents and WE want to enable message content intent this allows the bot to receive message content in most messages and then reply to it later on after saving those changes WE just need to authenticate the bot WE’m going to head to Olaf too and WE’m going to update the default authorization link here WE’m going to select the option custom URL and WE’m going to paste the following you are relin which is discord.com/auth two authorize with a scope permissions and client ID here the client ID WE’m going to grab from my client information and just place that in then WE can copy that entire link WE can open that up in Chrome and WE should be able to now authorize my own bot to run in my own server WE’m also going to give this Blood permissions as an administrator and this will allow it to do different things like application commands if WE want to add passing the following which is Gateway intent bits.gills.guild messages and Dot message content now WE’m going to move on to the open AI configuration for the API this is the most up-to-date configuration so WE’m going to cost and WE’m going to pull out the values of configuration as well as openai API and these WE’m going to require from the new package open AI WE’m going to initialize the configuration by calling in const configuration equals new configuration with capital c WE’m going to pass in the organization which WE’m going to pull out from the environmental key that WE earlier set as well as the API key which WE’m also going to pull out of the environmental key WE can now use this configuration to create a connection to open Ai and it’s API here WE’m going to constant open AI equals new open AI API and passing the configuration moving on to Discord WE’m going to use the Discord this will be an async function that will be pulling out the message from the messages that come from Discord users for this WE want to do a try catch Loop so that in case there are any errors WE can lock them out here if WE catch an error WE’m just going to console log it and now WE want to do a ping pong message where if a user sends a message WE get the bot to essentially say the message back to me firstly WE’ll console out a message WE use a sentence by doing console log message.content then WE’m going to do a reply of the same content in the reply WE’ll say you said with the message content itself and now we can connect this spot to the Discord server this is the easy part WE’ll call client login and pass in the environmental key for the Discord token WE might as well also console log that the chat GPt so that WE know once WE start the server since WE don’t have my API keys from openai yet WE’ll just comment out that bit of code to test out this message create code WE’m going to run the server by calling node index.js? Sunlight WE can now check this let me go into Discord and see and there it is we’ve got the chat GPt chatbot up and running it’s got the green circle and here if WE test that a message saying something like hi Char GPT how are you there hopefully WE get a response of a ping pong message and yes it continuously is pinging even itself so WE better quickly cancel that Discord server and WE’m going to fix that up WE want the ball to ignore messages from itself so WE’m going to pass in If the message dot author dot but is well essentially a butt or it’s true then it just returns this function so that it doesn’t continue on to the second or additional lines making sure that the pot doesn’t respond to itself or other Bots can be a good practice to have in making any type of Discord but now WE’ll relaunch the server it should be now online and WE’m going to give it a test let’s hope that this works now and WE should get a single reply which WE have without any additional ping next WE’m going to head over to the open AI website WE’m going to log into their dashboard and WE’m going to pull out the API key and the organization key WE’m going to head to the top right and select a view API keys and here WE’m going to generate a new secret key which WE’ll dispose off later after this article WE’m going to head back to vs code and WE’m going to head over to the dot EnV file and paste it here under openai underscore key WE also need the organization ID so WE’m going to head over to settings and WE’m going to head to the organization ID over here and copy and paste that and also place it into the vs code file here under the variable open AI underscore o r g after that WE’m going to head back to my index.js file and WE’m going to uncomment this open AI configuration with all the keys and organization set this is now ready for use so WE can remove this console log as well as this message and start crafting a new one WE’ll begin with constant GPT resp how are you the response will then be from either myself or actually even just from a member from the Discord channel so in this case WE can pass in the message.author.user name which in this case will be Adrian if WE’m sending a message on Discord with the message content being the value message dot content then WE’are going to break the line –

WE’m finally going to finish off this prompt with a chat GPT as well as a blank item here so this is where it begins it’s response next WE’ll update the message reply the message reply will be coming from chat GPT as a pot so all WE need to put here is the response that we get back from openai here WE’ll pass in GPT response dot dot dot choices index zero text and that is it WE can now do a return because of this is now ready for use in the terminal WE’m going to run no JS by calling no space index.js this will start the chatbot and WE can jump back into Discord to test it out so the Moment of Truth let me ask a question here got web design and see if it comes back with a response and success looks like it’s working it’s taken in the message and the content and is replied with a message that is related to that and specifically to me as well this means that WE should be able to continuously ask questions like are you a chatbot and WE should continuously get responses this is just the beginning of what chat GPt can do as a Discord – This Is how to add chatgpt to discord –

How to add ChatGpt TO Discord server – Video

chatgpt for Discord

If you want to test the MACOS venture then you can see our dedicated post here

Leave a Reply