{"id":13811,"date":"2023-02-24T14:10:46","date_gmt":"2023-02-24T11:10:46","guid":{"rendered":"https:\/\/unihost.com\/help\/?p=13811"},"modified":"2025-12-28T22:30:35","modified_gmt":"2025-12-28T19:30:35","slug":"openai-chatgtp-python","status":"publish","type":"post","link":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/","title":{"rendered":"Create telegram bot of OpenAI ChatGTP in Python"},"content":{"rendered":"<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Creating chatbots is becoming increasingly popular in the world of technology. They are used in a variety of fields, from customer support to education and medicine. However, developing a chatbot can be quite a daunting task, requiring a deep knowledge of programming and artificial intelligence. In this article, we will look at how to use OpenAI ChatGPT to create a Python-based Telegram bot that will communicate with users using natural language.<\/span><br \/>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><!--more--><\/span><\/p>\n<h2><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Content:<\/span><\/h2>\n<ul>\n<li><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Creating an OpenAI account and API key<\/span><\/li>\n<li><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Creating a telegram bot<\/span><\/li>\n<li><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Preparing the server, running the bot<\/span><\/li>\n<\/ul>\n<h2><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">1. Creation of account and OpenAI API key<\/span><\/h2>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Go to the <a href=\"https:\/\/openai.com\/api\/\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">OpenAI<\/a> page and create your account.<br \/>\nYou can sign up with an email address or you can continue with an existing Google or Microsoft account.\u00a0<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-13746 aligncenter\" src=\"https:\/\/unihost.com\/help\/minio.php?Screenshot-from-2023-02-23-12-07-01.png\" alt=\"\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f OpenAI\" width=\"566\" height=\"424\" \/ title=\"Create telegram bot of OpenAI ChatGTP in Python - Image 1\"><\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">The next step is to enter the number to which a confirmation SMS will be sent. \u00a0<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>Note<\/strong>, OpenAI is not available in all countries. See the <a href=\"https:\/\/platform.openai.com\/docs\/supported-countries\" target=\"_blank\" rel=\"noopener nofollow noopener noreferrer\">Supported countries and territories<\/a> link for a list of supported countries.<\/span><\/pre>\n<h2><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Creating API key<\/span><\/h2>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Click on your avatar in the upper right corner and select <strong>View API Keys. <\/strong>Click <strong>Create new secret Key<\/strong> to create the API key and copy it.<br \/>\n<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><strong>Attention!<\/strong> Make sure you save the key, as you won't be able to copy it when you log in again. If you lose it, you will need to generate a new key.<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-13751 aligncenter\" src=\"https:\/\/unihost.com\/help\/minio.php?Screenshot-from-2023-02-23-12-17-22.png\" alt=\"OpenAI API key\" width=\"691\" height=\"551\" \/ title=\"Create telegram bot of OpenAI ChatGTP in Python - Image 2\"><\/span><\/p>\n<h2><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">2. Creating a telegram bot<\/span><\/h2>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">We will use a special bot <a href=\"https:\/\/t.me\/BotFather\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">@BotFather<\/a> to create a telegram bot.<br \/>\nAnd so, to create a new bot, run the command:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">\/newbot<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Next, assign a name and a nickname to the bot \u2014 you will be able to find the bot in Telegram by it. The nickname should be unique, in Latin characters and must end in bot.<br \/>\nFor our example, let&#8217;s specify the nickname<strong> &#8211; uni_chat_gpt_bot<\/strong><\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">After the bot is created, you will see the following message:<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13766 aligncenter\" src=\"https:\/\/unihost.com\/help\/minio.php?Screenshot-from-2023-02-23-13-42-15.png\" alt=\"telegram bot token\" width=\"522\" height=\"284\" \/ title=\"Create telegram bot of OpenAI ChatGTP in Python - Image 3\"><\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">For us it is important token generated when creating the bot, we will use it in the future to integrate with OpenAI ChatGTP.<\/span><\/p>\n<h2><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">3. Preparing the server, running the bot<\/span><\/h2>\n<p><span style=\"font-size: 12pt; font-family: Ubuntu, sans-serif;\">In this tutorial we will create a simple chatbot using the <a href=\"https:\/\/platform.openai.com\/docs\/models\/davinci-002\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Davinci<\/a> AI model for generating responses. It is an accurate and expensive model, but it is slower because it works with a <a href=\"https:\/\/platform.openai.com\/docs\/api-reference\/embeddings\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">lot of data<\/a>. It can do the tasks of all the other models, but requires less guidance in the &#8220;Instructions for the bot&#8221;.<\/span><\/p>\n<p><span style=\"font-size: 12pt; font-family: Ubuntu, sans-serif;\">In the <a href=\"https:\/\/platform.openai.com\/docs\/examples\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Examples<\/a> and <a href=\"https:\/\/github.com\/openai\/openai-cookbook\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">OpenAI Cookbook<\/a> sections, you can see examples of how to use the models, as well as experiment with the settings in <a href=\"https:\/\/platform.openai.com\/playground\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Playground<\/a>.<\/span><\/p>\n<p><span style=\"font-size: 12pt; font-family: Ubuntu, sans-serif;\">For the example in this tutorial, we&#8217;ve chosen the <a href=\"https:\/\/platform.openai.com\/examples\/default-friend-chat\" rel=\"nofollow noopener noreferrer\" target=\"_blank\">Friend chat<\/a> pattern, which is a text-based conversation emulation. As a basis, we will take the API-request for Python of this template, but we will edit it to our requirements.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">And so it&#8217;s time to create and host the Python script on the server. We will use a <a href=\"https:\/\/unihost.com\/vps\/\">VPS<\/a> based on Ubuntu Server 20.04.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Logging into the server via SSH.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">By default, Ubuntu Server 20.04 already has python version 3 installed.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">To check, enter the command:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">python3<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Answer:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Python 3.8.10 (default, Nov 14 2022, 12:59:47) <\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">[GCC 9.4.0] on linux<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">&gt;&gt;&gt;<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">this means that Python 3.8.10 is already installed on the server and we can proceed to the next step.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Install pip:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">apt install pip<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Install the necessary libraries for our script:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">pip install openai<\/span>\n\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">pip install pyTelegramBotAPI<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Create the file <em>main.py<\/em>:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">nano main.py<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Insert the following code:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">import os<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">import openai<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">import telebot<\/span>\n\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">openai.api_key = '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'<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">bot = telebot.TeleBot('5868492437:AAHzr8E09ooGpXNw7lOf2On2K53FKz-ZTyc')<\/span>\n\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">@bot.message_handler(func=lambda _: True)<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">def handle_message(message):<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">response = openai.Completion.create(<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">model=\"text-davinci-003\",<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">prompt=message.text,<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">temperature=0.5,<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">max_tokens=60,<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">top_p=1.0,<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">frequency_penalty=0.5,<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">presence_penalty=0.0,<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">)<\/span>\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">bot.send_message(chat_id=message.from_user.id, text=response['choices'][0]['text'])<\/span>\n\n<span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">bot.polling()<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Where,<\/span><\/p>\n<pre><span style=\"font-size: 12pt; font-family: Ubuntu, sans-serif;\">openai.api_key = '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'\n\nAPI-key OpenAI<\/span><\/pre>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">bot = telebot.TeleBot('5868492437:AAHzr8E09ooGpXNw7lOf2On2K53FKz-ZTyc')\n\nTelegram chatbot API key\n<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Accordingly, they must be replaced with your own.<\/span><\/p>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">Run the script:<\/span><\/p>\n<pre><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">python3 main.py<\/span><\/pre>\n<p><span style=\"font-family: Ubuntu, sans-serif; font-size: 12pt;\">If no errors are not detected, you can proceed to the testing of our Telegram-bot, to do this, you need to find it by nickname &#8211; <strong>uni_chat_gpt_bot<\/strong> and you can start a dialogue:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-13793 aligncenter\" src=\"https:\/\/unihost.com\/help\/minio.php?photo_2023-02-23_16-42-15.jpg\" alt=\"chatgpt bot\" width=\"551\" height=\"346\" \/ title=\"Create telegram bot of OpenAI ChatGTP in Python - Image 4\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Creating chatbots is becoming increasingly popular in the world of technology. They are used in a variety of fields, from customer support to education and medicine. However, developing a chatbot can be quite a daunting task, requiring a deep knowledge of programming and artificial intelligence. In this article, we will look at how to use [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[158,69],"tags":[761,762,459],"class_list":["post-13811","post","type-post","status-publish","format-standard","hentry","category-dedicated-servers","category-dedicated-servers-ru","tag-chatgpt-2","tag-openai-2","tag-python-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create telegram bot of OpenAI ChatGTP in Python<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to easily create a Telegram chatbot for OpenAI in Python - Unihost.FAQ\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create telegram bot of OpenAI ChatGTP in Python\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to easily create a Telegram chatbot for OpenAI in Python - Unihost.FAQ\" \/>\n<meta property=\"og:url\" content=\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Unihost.FAQ\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/unihost\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-02-24T11:10:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-28T19:30:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/unihost.com\/help\/wp-content\/uploads\/Screenshot-from-2023-02-23-12-07-01.png\" \/>\n<meta name=\"author\" content=\"Unihost Support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@unihost\" \/>\n<meta name=\"twitter:site\" content=\"@unihost\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Unihost Support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/\"},\"author\":{\"name\":\"Unihost Support\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a\"},\"headline\":\"Create telegram bot of OpenAI ChatGTP in Python\",\"datePublished\":\"2023-02-24T11:10:46+00:00\",\"dateModified\":\"2025-12-28T19:30:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/\"},\"wordCount\":543,\"publisher\":{\"@id\":\"https:\/\/unihost.com\/help\/#organization\"},\"image\":{\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/unihost.com\/help\/wp-content\/uploads\/Screenshot-from-2023-02-23-12-07-01.png\",\"keywords\":[\"ChatGPT\",\"OpenAI\",\"python\"],\"articleSection\":[\"02. Dedicated servers\",\"02. \u0421\u0435\u0440\u0432\u0435\u0440\u044b\"],\"inLanguage\":\"en\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/\",\"url\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/\",\"name\":\"Create telegram bot of OpenAI ChatGTP in Python\",\"isPartOf\":{\"@id\":\"https:\/\/unihost.com\/help\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/unihost.com\/help\/wp-content\/uploads\/Screenshot-from-2023-02-23-12-07-01.png\",\"datePublished\":\"2023-02-24T11:10:46+00:00\",\"dateModified\":\"2025-12-28T19:30:35+00:00\",\"description\":\"This tutorial will show you how to easily create a Telegram chatbot for OpenAI in Python - Unihost.FAQ\",\"breadcrumb\":{\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#breadcrumb\"},\"inLanguage\":\"en\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage\",\"url\":\"https:\/\/unihost.com\/help\/minio.php?Screenshot-from-2023-02-23-12-07-01.png\",\"contentUrl\":\"https:\/\/unihost.com\/help\/minio.php?Screenshot-from-2023-02-23-12-07-01.png\",\"width\":566,\"height\":424,\"caption\":\"\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f OpenAI\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Unihost\",\"item\":\"https:\/\/unihost.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Help\",\"item\":\"https:\/\/unihost.com\/help\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Create telegram bot of OpenAI ChatGTP in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/unihost.com\/help\/#website\",\"url\":\"https:\/\/unihost.com\/help\/\",\"name\":\"Unihost.FAQ\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/unihost.com\/help\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/unihost.com\/help\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/unihost.com\/help\/#organization\",\"name\":\"Unihost\",\"alternateName\":\"Unihost\",\"url\":\"https:\/\/unihost.com\/help\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png\",\"contentUrl\":\"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png\",\"width\":300,\"height\":300,\"caption\":\"Unihost\"},\"image\":{\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/unihost\/\",\"https:\/\/x.com\/unihost\",\"https:\/\/www.instagram.com\/unihost\/?hl=en\",\"https:\/\/www.linkedin.com\/company\/unihost-com\",\"https:\/\/www.youtube.com\/channel\/UCITKsxMDnslQY8brN3advgw\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a\",\"name\":\"Unihost Support\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en\",\"@id\":\"https:\/\/unihost.com\/help\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g\",\"caption\":\"Unihost Support\"},\"sameAs\":[\"https:\/\/unihost.com\/\"],\"url\":\"https:\/\/unihost.com\/help\/author\/support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create telegram bot of OpenAI ChatGTP in Python","description":"This tutorial will show you how to easily create a Telegram chatbot for OpenAI in Python - Unihost.FAQ","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/","og_locale":"en_US","og_type":"article","og_title":"Create telegram bot of OpenAI ChatGTP in Python","og_description":"This tutorial will show you how to easily create a Telegram chatbot for OpenAI in Python - Unihost.FAQ","og_url":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/","og_site_name":"Unihost.FAQ","article_publisher":"https:\/\/www.facebook.com\/unihost\/","article_published_time":"2023-02-24T11:10:46+00:00","article_modified_time":"2025-12-28T19:30:35+00:00","og_image":[{"url":"https:\/\/unihost.com\/help\/wp-content\/uploads\/Screenshot-from-2023-02-23-12-07-01.png","type":"","width":"","height":""}],"author":"Unihost Support","twitter_card":"summary_large_image","twitter_creator":"@unihost","twitter_site":"@unihost","twitter_misc":{"Written by":"Unihost Support","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#article","isPartOf":{"@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/"},"author":{"name":"Unihost Support","@id":"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a"},"headline":"Create telegram bot of OpenAI ChatGTP in Python","datePublished":"2023-02-24T11:10:46+00:00","dateModified":"2025-12-28T19:30:35+00:00","mainEntityOfPage":{"@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/"},"wordCount":543,"publisher":{"@id":"https:\/\/unihost.com\/help\/#organization"},"image":{"@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage"},"thumbnailUrl":"https:\/\/unihost.com\/help\/wp-content\/uploads\/Screenshot-from-2023-02-23-12-07-01.png","keywords":["ChatGPT","OpenAI","python"],"articleSection":["02. Dedicated servers","02. \u0421\u0435\u0440\u0432\u0435\u0440\u044b"],"inLanguage":"en"},{"@type":"WebPage","@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/","url":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/","name":"Create telegram bot of OpenAI ChatGTP in Python","isPartOf":{"@id":"https:\/\/unihost.com\/help\/#website"},"primaryImageOfPage":{"@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage"},"image":{"@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage"},"thumbnailUrl":"https:\/\/unihost.com\/help\/wp-content\/uploads\/Screenshot-from-2023-02-23-12-07-01.png","datePublished":"2023-02-24T11:10:46+00:00","dateModified":"2025-12-28T19:30:35+00:00","description":"This tutorial will show you how to easily create a Telegram chatbot for OpenAI in Python - Unihost.FAQ","breadcrumb":{"@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/unihost.com\/help\/openai-chatgtp-python\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#primaryimage","url":"https:\/\/unihost.com\/help\/minio.php?Screenshot-from-2023-02-23-12-07-01.png","contentUrl":"https:\/\/unihost.com\/help\/minio.php?Screenshot-from-2023-02-23-12-07-01.png","width":566,"height":424,"caption":"\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f OpenAI"},{"@type":"BreadcrumbList","@id":"https:\/\/unihost.com\/help\/openai-chatgtp-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Unihost","item":"https:\/\/unihost.com\/"},{"@type":"ListItem","position":2,"name":"Help","item":"https:\/\/unihost.com\/help\/"},{"@type":"ListItem","position":3,"name":"Create telegram bot of OpenAI ChatGTP in Python"}]},{"@type":"WebSite","@id":"https:\/\/unihost.com\/help\/#website","url":"https:\/\/unihost.com\/help\/","name":"Unihost.FAQ","description":"","publisher":{"@id":"https:\/\/unihost.com\/help\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/unihost.com\/help\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/unihost.com\/help\/#organization","name":"Unihost","alternateName":"Unihost","url":"https:\/\/unihost.com\/help\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/","url":"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png","contentUrl":"https:\/\/unihost.com\/help\/minio.php?2026\/01\/minio.png","width":300,"height":300,"caption":"Unihost"},"image":{"@id":"https:\/\/unihost.com\/help\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/unihost\/","https:\/\/x.com\/unihost","https:\/\/www.instagram.com\/unihost\/?hl=en","https:\/\/www.linkedin.com\/company\/unihost-com","https:\/\/www.youtube.com\/channel\/UCITKsxMDnslQY8brN3advgw"]},{"@type":"Person","@id":"https:\/\/unihost.com\/help\/#\/schema\/person\/bb5ae95f38577c920e6a7507888b715a","name":"Unihost Support","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/unihost.com\/help\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a0c9db17c2a0d93e8a0d5ac123f8c5db750ad4d3d5657369c0c4e480f5af77b8?s=96&d=mm&r=g","caption":"Unihost Support"},"sameAs":["https:\/\/unihost.com\/"],"url":"https:\/\/unihost.com\/help\/author\/support\/"}]}},"_links":{"self":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts\/13811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/comments?post=13811"}],"version-history":[{"count":12,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts\/13811\/revisions"}],"predecessor-version":[{"id":19584,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/posts\/13811\/revisions\/19584"}],"wp:attachment":[{"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/media?parent=13811"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/categories?post=13811"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unihost.com\/help\/wp-json\/wp\/v2\/tags?post=13811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}