fertdetroit.blogg.se

Telegram messenger bot
Telegram messenger bot













telegram messenger bot
  1. TELEGRAM MESSENGER BOT INSTALL
  2. TELEGRAM MESSENGER BOT CODE

You will get the following response in your telegram.Īdd the code to get the Inline Button to the telegram. def tel_send_inlinebutton(chat_id):Īdd this code to your index function. elif txt = "button":Īdd the code to get the Inline Button to the telegram. 'reply_markup': Īdd this code to your index function. elif txt = "poll":Īdd the code to get the Button to the telegram bot. "options": json.dumps(),Īdd this code to your index function. "question": "In which direction does the sun rise?", elif txt = "file":Īdd the code to get the Poll to the telegram. To add more parameters you can follow the Documentation. def tel_send_document(chat_id):Īdd this code to your index function. You will get the following response in your telegram like this.Īdd the code to get the File to the telegram. To add more parameters you can follow the Documentation. def tel_send_video(chat_id):Īdd this code to your index function.

telegram messenger bot

elif txt = "audio":Īdd the code to get the video to the telegram. To add more parameters you can follow the Documentation. def tel_send_audio(chat_id):Īdd this code to your index function. Similar way you can send audio to the telegram. For more parameters, you can follow the Documentation. Here is the response that you will get from the telegram. Tel_send_message(chat_id, 'from webhook') Tel_send_message(chat_id,"Hello, world!") Now we can also get the image from the telegram bot.īy adding the function for sending images in the code.įor more parameters, you can follow the Documentation.

telegram messenger bot

We will get the below response in the Telegram Bot. You can also add an extra parameter in send message for that you can follow the Documentation. We will write the code to get the response for the “hi” message from the user and if anything other than “hi” is imputed then response with “from webhook”. Step 11: send the text message from the bot. Here we can see that the message that we have written to the telegram bot we can get at the backend in text. Then type any message that you want such as “test bot” or anything you want.Īfter writing “test bot” to your bot now go to the Vscode you will file the following JSON in your terminal. In BotFather where you get the token for your Telegram chatbot, you can also file the URL to redirect to your Telegram bot.Īfter that click on the Start Bot to start the chat with the bot. Now open VS Code and add the following code and run it on the same Ngrok link on which you had run the previous code. Now we will need to get the JSON response from the telegram bot for any text that we write to the bot. Īfter running the link in your web browser you will get the response shown in the bellow image. You can do it by running the link in your browser. Now you will need to set the webhook for the telegram bot. You will see the response “Welcome!” same as the previous step. Go to the Ngrok and type the command “ngrok http 5000” after running this command you will get the links.įrom that Ngrok links copy the HTTPS link and paste it to your browser. When you run the code you will get the link for the server like “ ” click on that link you will be redirected to the webpage where you will see the response “Welcome!” Run this code to check whether the flask app is running correctly or not.

TELEGRAM MESSENGER BOT INSTALL

$ pip install Flask from flask import Flask Step 7: Creating a flask app for the webhook response.įirst of all, you will need to install python and flask on your computer. Keep your token secure and store it safely. it contains a token to access the HTTP API. Step 6: After giving a unique username you will get a message like the below. Step 5: Now type a unique username for your bot. Step 2: Click on the “BotFather” and Click on the “Start” button. Step 1: Open your telegram account and in the search bar type “BotFather”. Here we learn how we can get different types of responses from the bot such as:įollow the below instructions to make a Telegram chatbot. In this tutorial, we will learn about how we can create a Telegram chatbot and use it to prepare text messages with rich responses. On platforms such as Facebook, Google, and others, we can develop chatbots. For engaging conversations, the automated chatbot is really beneficial.















Telegram messenger bot