✈️Add to Telegram

Build an AskAI bot that can answer questions in Telegram without writing a single line of code.

  1. Set up a new bot in Telegram 0:01

First, open Telegram and search for the "BotFather" bot. Type "/start" and follow the instructions to create a new bot. Be sure to name your bot something that ends with "bot".

  1. Get your API token 0:17

After creating your bot, the BotFather will provide you with an API token. Copy and store this token for later use.

  1. Build a flow 0:34

Next, create a flow that includes a Telegram bot watching for updates, an HTTP request to the AskAI webhook, and a text message to send the response back to the user.

  1. Connect your Telegram bot to the flow 0:56

In the "Watch Updates" block, add a connection and paste the API token you obtained earlier from the BotFather.

  1. Make an HTTP request to AskAI 1:06

Create a POST request using the URL and request content provided by AskAI. To find this information, go to AskAI's "Embed and Integrate" section and click on "API Access". Make sure the headers, body type, and content type match what is shown in the video.

  1. Replace the placeholder with message text 2:08

In the body of the HTTP request, replace "insert your question" with the message text coming from Telegram. You can simply drag the "Message.Text" field from Telegram into the appropriate spot.

  1. Parse the JSON response 2:27

To display a shorter message in your Telegram bot, first parse the JSON response from AskAI. In the "JSON.String" field, insert the data from the HTTP request.

  1. Send the message back to the user 2:53

Finally, use the "SendMessage" block to send the parsed answer back to the user. Insert the chat ID and the parsed answer, leaving some space for reference links.

  1. Add a filter to prevent a message from being sent on your first β€˜reply’

After your Telegram β€œWatch updates” bot add a filter with the condition 1. Messages: Text and choose: β€œText operators: Does not contain” then enter β€œ/start” into the text field. This will ensure that a reply isn’t triggered when the bot initiates.

  1. Test your bot 3:24

Click "Run once" and wait for new data. Then, go to your bot in Telegram and type a question. For example, you can ask: "What is your returns policy?"

  1. Receive the answer 3:45

After sending the question, the webhook will process your request and send the answer back to your Telegram bot. The response will include the answer along with any references.

  1. Customize the response (optional) 3:59

If you want to shorten the answer or change the answer style, you can do so by going to AskAI and customizing the response settings.

Remember that this integration is for the "Explain" mode and does not support the conversational chat feature.

Last updated