telegram_openai_assistant
telegram_openai_assistant copied to clipboard
Telegram Bot using GPT4 beta assistant api.
OpenAI Assistant Telegram Bot
This repository provides a general framework for integrating an OpenAI Assistant with a Telegram bot. It allows users to interact with the OpenAI-powered conversational agent through the Telegram platform.
Features
- Real-time response to user queries.
- Daily message count tracking.
- Storage of question and answer pairs for future retrieval and analysis.
Prerequisites
Before you begin, ensure you have met the following requirements:
- You have a
Python
environment running version 3.7+. - You have a Telegram account and have created a bot with
@BotFather
to obtain a token. - You have an
OpenAI
account to obtain your API keys.
You also need
- An open ai assistant id : https://platform.openai.com/assistants
- An open ai API key : https://platform.openai.com/api-keys
- A telegram token : use botfather directly from telegram to create your bot and get the telegram token
Installation
Clone the repository to your local machine:
git clone https://github.com/efelem/telegram_openai_assistant
cd telegram_openai_assistant
Install the packages:
pip install -e .
Configuration
Create a .env
file in the root directory and fill in your OpenAI and Telegram credentials:
ASSISTANT_ID=your-assistant-id
CLIENT_API_KEY=your-openai-api-key
TELEGRAM_TOKEN=your-telegram-bot-token
Usage
To start the bot, run the following command in your terminal:
chatbot
The bot should now be running and can be interacted with through your Telegram bot interface.
Launching the Telegram Bot Client on DeepSquare
You can easily launch the Telegram bot client using the job.telegram_openai_assistant.yaml
workflow file in our repository. Follow these simple steps to get started:
Launching through the DeepSquare Platform
- Log in to the DeepSquare Platform: Ensure you are logged into app.deepsquare.run.
- Navigate to Workflows: Go to the 'Workflows' section in the platform.
-
Create a new Workflow: Click on the 'New Workflow' and copy paste the content of the
job.telegram_openai_assistant.yaml
file - Start the Workflow: Once created, you can start the workflow by clicking on the 'Run Workflow' button.
- Monitor and Access: Monitor the progress of your job under the 'Jobs' section. Upon completion, access the Telegram bot as per the instructions provided in the job logs.
Launching through the DeepSquare Command Line Tool
-
Install DeepSquare CLI: If you haven’t already, install the DeepSquare CLI tool. Instructions can be found here.
-
Clone the Repository: Clone the repository containing the
job.telegram_openai_assistant.yaml
file. -
Navigate to the Repository Directory: Open a terminal and navigate to the directory where you cloned the repository.
-
Run the Workflow File: Execute the following command:
deepsquare run job.telegram_openai_assistant.yaml
-
Monitor the Job: Use the following command to monitor the status of your job:
deepsquare status
-
Access the Telegram Bot: Once the job is complete, follow the instructions provided in the job logs to access and interact with the Telegram bot.
By following these steps, you can effortlessly launch and interact with the Telegram bot client on DeepSquare.
Contributions
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
- Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
- Push to the Branch (`git push origin feature/AmazingFeature`)
- Open a Pull Request
License
Distributed under the MIT License. See `LICENSE` for more information.
Contact
Project Link: https://github.com/efelem/telegram_openai_assistant