How to Integrate ChatGPT with Telegram

Guide to integrate ChatGPT with Telegram
Reading Time: 4 minutes

Do you want to access ChatGPT directly from Telegram, save the conversation, or forward the conversation to a friend or colleague? Are you constantly switching between your messaging app and your web browser to get answers to your questions? No longer do you have to. Create a ChatGPT Telegram bot and use ChatGPT in Telegram.

We can easily integrate ChatGPT with Telegram by creating a Telegram bot that’s essentially ChatGPT but as a bot in Telegram. Once we’ve connected ChatGPT to Telegram, we can get access to all the features of ChatGPT, such as composing emails, writing and debugging code, providing helpful information, and much more. Additionally, we can use voice to chat with ChatGPT.

With ChatGPT in Telegram, we can get instant answers to all our questions without ever leaving the app. So, without further delay, let’s learn how to integrate ChatGPT with Telegram and how to use ChatGPT in Telegram.

Accessing ChatGPT from Telegram

This tutorial covers how to integrate ChatGPT with Telegram and use ChatGPT in Telegram. To get your hands on it and get a taste of it, you can try a ChatGPT Telegram bot that has already been created.

Click on the ChatGPT Telegram bot link to chat with ChatGPT from Telegram: @chatgpt_karfly_bot

ChatGPT bot in Telegram - Integrate ChatGPT with Telegram

On connecting to the ChatGPT Telegram bot, you’ll be shown a few commands and the chat mode–the mode to use ChatGPT in Telegram for. Select the suitable option according to what you want to do with the ChatGPT Telegram bot.

Using ChatGPT in Telegram - integrate ChatGPT with Telegram

You can also use this ChatGPT Telegram bot to access ChatGPT from Telegram which gives you more free tokens. It has practically the same functionality but is fluent in more languages: @LunaGPTBot

You can only have a limited number of free conversations with the bot. To increase the quota, you need to buy more tokens from the bot creator. So let us create our own bot with our own tokens.

If you want to create your own bot to integrate ChatGPT with Telegram using your OpenAI API key, follow the tutorial below.

Related: How to integrate ChatGPT with WhatsApp

Requirements to integrate ChatGPT with Telegram

There are a few ways to integrate ChatGPT with Telegram. For this tutorial, we’ll be using a repository from GitHub to integrate ChatGPT with Telegram.

Here are a few things that you’ll need to have on your computer:

  • Python (and a few Python packages, which need not be installed separately)
  • MongoDB
  • Docker

And the following to create a Telegram bot and connect ChatGPT to Telegram:

  • The ChatGPT Telegram bot GitHub repository
  • OpenAI API key
  • Telegram bot token

Steps to integrate ChatGPT with Telegram

Getting started

  • Go to the ChatGPT Telegram bot GitHub repository and download the repository. Click here to clone it. Then unzip the file.
  • Get the OpenAI API key.
    • Obtain an API key from OpenAI. The API key can be found in the User Settings.
    • If you don’t have the secret key saved, you can create a new one by clicking the “+ Create new secret key” button. Keep the key safe and confidential; the key will not be displayed again.
OpenAI API key

Related: How to Use ChatGPT for Coding to Get Higher Output

Setting up the ChatGPT and Telegram integration

1. Open the config folder and edit the config.example.yml. Enter the Telegram bot token and the ChatGPT API key.

Config file - Integrate ChatGPT with Telegram

You can also specify the users to whom to make the bot available. Then save and close the file.

2. Rename the config.example.yml file to config.yml and config.example.env to config.env

3. Open Terminal or Command Prompt and navigate to the Telegram bot directory and run the following command. (You can also open the chat_gpt_telegram_bot-main folder and open Terminal or Command Prompt from there.)

docker-compose --env-file config/config.env up --build

On running the above command, the required packages will be installed and a Docker container image will be created that hosts the ChatGPT Telegram bot.

If all goes right, you’ll be to use ChatGPT from Telegram. Simply message the bot using the bot username you’ve given and chat with it. It will respond as ChatGPT does but in Telegram.

You can configure and modify existing chat modes or add different chat modes with your own prompt by editing the chat_modes.yml file in the config folder.

If for some reason, you are not able to successfully integrate ChatGPT with Telegram (as there are several ways things may fail to work), you can also try this ChatGPT Telegram bot.

Some recommended articles

Complete guide to WhatsApp Cloud API

How to connect Facebook Ads to Google Sheets

Import Data From YouTube Analytics To Google Sheets

7 responses to “How to Integrate ChatGPT with Telegram”

  1. I hace some questions wich answer I don’t find anywhere:

    (this one the most important)-Can I create my own chatgpt bot and use it for free? Or I have to connect to an openAI account and buy tokens from openAI to use the API? Or is what you call the Key? Are they free or you have to purchase it?

    -You say “to buy tokens from the bot creator”. But if we buy tokens from openAI is not the same? Or the bot is not related to our openAI account?

    • Hi David, you can create your own ChatGPT Telegram bot using your OpenAI API key. You have to pay for the API to use it, unless you have some free credits.

      Buying tokens from the bot creator is a different thing. You are paying the bot creator to access the API using their tokens. The bot in Telegram is not an official ChatGPT bot, so it’s not in any way related with OpenAI.

  2. Utopia P2P encrypted messenger just released the ChatGPT function, and it’s a game-changer! The new feature provides users with an intelligent chatbot that can answer any question they might have. Compared to Telegram, Utopia’s ChatGPT function offers better accuracy and response time.

    • You can add chat modes or modify the existing chat modes by editing the chat_modes.yml file in the “config” folder.

  3. I’m trying to deply my own bot and receive “something went wrong during completion. Reason: you exceeded your current quota, please check your plan and billing details”.

    • I assume you’re on the free plan and that you’ve used up all your free credits. Upgrade to a paid plan and generate a new API key after you’ve upgraded.

Leave a Reply