This is a nodejs code for creating a Telegram bot that uses the ChatGPT API to generate responses to user messages.
git clone https://github.com/azoway/chatgpt-telegram-bot
cd chatgpt-telegram-bot
npm install
vi index.js
node index.js
- Obtain a Telegram bot token from BotFather and replace the value of telegram_bot_token with your token.
- Obtain an API key for the ChatGPT API and replace the value of apiKey with your key.
- Optionally, change the group_name variable to specify a different name for your bot's command prefix (default is /gpt).
- Modify the allowedUserIds array to include the IDs of the Telegram users and groups that are allowed to interact with your bot.
- Run the following command to start the bot:
node index.js
- Send a message to your bot in Telegram to initiate a conversation. You can use the /reset command to clear the conversation history and start over.