openai-chatbot
v1.0.1
Published
A simple module to develop chatbots using the OpenAI ChatGPT API
Downloads
36
Maintainers
Readme
OpenAI Chatbot Module This module allows developers to easily integrate an OpenAI ChatGPT-powered chatbot with Telegram.
Installation To install the module, use npm:
bash Copy code npm install openai-chatbot Setup Create a .env file:
Create a .env file in your project directory with the following content. Replace your-openai-api-key-here and your-telegram-bot-token-here with your actual OpenAI API key and Telegram bot token.
dotenv Copy code OPENAI_API_KEY=your-openai-api-key-here TELEGRAM_TOKEN=your-telegram-bot-token-here Dependencies:
Ensure you have the required dependencies (axios, dotenv, node-telegram-bot-api) installed in your project. If not, install them using:
bash Copy code npm install axios dotenv node-telegram-bot-api Usage javascript Copy code const OpenAIChatbot = require('openai-chatbot');
// Instantiate the chatbot (it will automatically start polling for Telegram messages) const chatbot = new OpenAIChatbot();
console.log('Telegram bot is running...');
// No need to send a message manually since the bot will handle incoming messages automatically Contributing Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.
License This project is licensed under the MIT License - see the LICENSE file for details.
Notes: Environment Variables: Ensure your .env file is correctly set up with your API keys before running your application. Telegram Bot Token: You can obtain a Telegram bot token by creating a new bot on Telegram through BotFather. OpenAI API Key: You need to sign up for OpenAI and obtain an API key from their platform. This README.md provides a clear guide for developers on how to install, set up, and use your OpenAI Chatbot module with Telegram. Adjust the content based on any specific configuration or additional features your module may offer.