This repository provides a framework for integrating AI-powered assistants with a Telegram bot. Currently, it supports OpenAI's conversational models, allowing users to interact seamlessly through Telegram.
Path Forward: We aim to expand this bot's capabilities by integrating support for additional AI platforms such as Anthropic's Claude, Google Bard, and Hugging Face Inference API. This will enable users to choose and switch between multiple AI providers.
- Real-time responses powered by OpenAI (current implementation).
- Modular design for future multi-platform AI support.
- Daily message count tracking.
- Storage of question and answer pairs for future retrieval and analysis.
Our next steps include:
- Designing a modular architecture to support multiple AI platforms.
- Adding compatibility with popular AI providers beyond OpenAI.
- Providing seamless configuration for selecting AI platforms in the
.env
file.
If you'd like to contribute to these efforts, check the Contributions section.
- Real-time response to user queries.
- Daily message count tracking.
- Storage of question and answer pairs for future retrieval and analysis.
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
Clone the repository to your local machine:
git clone https://github.com/efelem/telegram_openai_assistant
cd telegram_openai_assistant
Install the packages:
# If you want to create a venv
mkdir venv
python3 -m venv venv
source venv/bin/activate
# To install packages
pip install -e .
Create a .env
file in the root directory and fill in your OpenAI and Telegram credentials. For consistency, both TELEGRAM_TOKEN_BOT and ASSISTANT_ID_BOT support comma-separated lists for multiple bot configurations.
Example .env file:
TELEGRAM_TOKEN_BOT=bot1_token,bot2_token
ASSISTANT_ID_BOT=assistant1_id,assistant2_id
CLIENT_API_KEY=your-openai-api-key
If you have only one bot, simply provide a single value (e.g., bot1_token or assistant1_id). Tokens and IDs will be processed as lists automatically.
To start the bots, run the following command in your terminal:
chatbot
The bots should now be running and can be interacted with through your Telegram bot interface.
This is not working, until the testnet is up and running again, happening soon.
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:
- 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.
-
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.
We welcome contributions to support this path forward. Some potential areas for contribution include:
- Designing the modular framework for multiple AI platforms.
- Adding integrations for new AI platforms
- Improving bot configuration and management.
- Enhancing documentation for future developers and users.
- 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
Distributed under the MIT License. See `LICENSE` for more information.
Project Link: https://github.com/efelem/telegram_openai_assistant