🧠 How to Create a Telegram Bot with Agenticflow

Step 1: Create a New Bot on Telegram

  1. Open BotFather on Telegram and type on “Create New Bot”.
  2. Choose a name and username for your bot — make sure it’s something easy to remember and manage later.
  3. Once created, BotFather will give you a bot with a token.

:key: You’ll need this token later to connect your Telegram bot to your AgenticFlow agent using a webhook.

Step 2: Configure the Trigger

  1. Open the “Agents” tab

  2. Select the agent you want to edit

  3. Go to the “Trigger” sectionClick Button ‘‘Add’’

  4. Enter a name for your trigger (you don’t need to change any of the default settings).

  5. In the Message field, add the variable: {{event.body}}.

This means that whenever someone sends a message to your Telegram bot, the content of that message will automatically be wrapped inside the {{event.body}} variable. It allows your bot to capture and use the user’s input.

  1. The chat ID to send the message to. If not provided, a new chat will be created every time.

:backhand_index_pointing_right: If you want all messages to be grouped in a single chat tab, enter the exact Chat ID of that tab here.
:red_exclamation_mark:If you leave this blank, the bot will create a new chat tab for each incoming message from the Telegram bot — which can quickly become messy if you receive many messages.

This setting helps you control how conversations are organized inside Agenticflow Agents.


  1. Ok now, click the “Create” button. After that, you’ll see the webhook link for your agent.

Step 3: Link Your AgenticFlow Agent to Your Telegram Bot

To connect your Telegram bot to your AgenticFlow agent, you’ll need to set up the webhook using the terminal.

  1. :backhand_index_pointing_right: Open your terminal and run the following command:

curl --location "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/setWebhook?url=https://api.agenticflow.ai/v1/agents/webhook/<YOUR_AGENT_WEBHOOK_ID>/trigger"

:pushpin: Replace:

  • <YOUR_BOT_TOKEN> with the token you received from BotFather
  • <YOUR_AGENT_WEBHOOK_ID> with the webhook URL from your AgenticFlow agent

:white_check_mark: Example:

curl --location "https://api.telegram.org/bot7916346345:AAHOfyml1pqvaOg_IjwYLPeb8gU9LAQc9vE/setWebhook?url=https://api.agenticflow.ai/v1/agents/webhook/014a51be-7232-47c9-aa2d-b5ca4e1a3ed1/trigger"

If the response in your terminal says:

json

{"ok":true,"result":true,"description":"Webhook was set"}

:white_check_mark: That means your webhook setup was successful. Telegram has successfully linked your bot to the AgenticFlow agent.

Step 4: Now It’s Time to Adjust Your Agent to Do What You Want

Here’s what you need to do to get your Agent to work the way you want:

:green_square: 1. System Prompt

This is where you define what you want the Agent to do.
Write clearly in the prompt what kind of tasks or behavior you expect from the Agent.

For example:

  • "You are "QuizMaster’’ Telegram bot. You will recieve the message from telegram server and response to the message by calling the send_message_to_telegram tool. You are a friendly and expert English language tutor specializing in vocabulary. Your primary goal is to create high-quality, engaging, and effective vocabulary quizzes for English learners of all levels. Your tone should be encouraging, clear, and helpful.‘’

Be as specific and concise as possible so your Agent understands the context and how to respond.

:gear: 2. Workflow

You must include the Send message to Telegram workflow so the Agent can send updates to Telegram.

Here’s how to set it up:

:white_check_mark: Step-by-step:

:hammer_and_wrench: How to create the Telegram connection:

  1. Go to the Connections tab in Agenticflow.

  2. Click “Create new connection”.

  3. Choose Telegram as the type.

  4. Paste your Telegram Bot Token.

That’s it – your Telegram workflow will now be able to send messages via your Agent.

Additionally, you can add extra workflows like:

These optional workflows allow your Agent to handle more complex or multimedia tasks based on your needs.

However, remember this important rule:

:stop_sign: The Send message to Telegram workflow is mandatory when you’re creating an Agent for a Telegram bot.

No matter what else you add, this workflow must be included for your Agent to work properly with Telegram.

Step 5: Set up your Telegram bot inside Telegram

Now let’s switch back to Telegram to adjust your bot settings:

  1. Open Telegram and search for @BotFather

  2. Type ‘/mybots - edit your bots’’

  3. Choose the bot you want to configure.

  4. Click “Bot Settings”

  5. Select “Group Privacy”

  6. Click “Turn off” — this disables privacy mode.
    :white_check_mark: If it shows “Turn on”, that means privacy mode is now turned off (which is what we want).

:bell: Disabling privacy mode allows your agent to read all messages in a group.

:tada: Alright, final step – it’s time to test and use your Telegram bot! :tada:

  1. Create a new Telegram group.

  2. Add your bot to that group.

  3. Start chatting in the group!

:brain: Each message you send in the group will trigger your AgenticFlow agent to respond — and for every new message, AgenticFlow will create a new chat tab inside your agent’s Chat History.

:backhand_index_pointing_right: So don’t forget to check the Chat History section of your agent in AgenticFlow to see how it responds!

If you run into any issues while creating your Telegram chatbot, feel free to leave a comment — we’re here to help you out.

:loudspeaker: We’d love to see what you build!
Once your Telegram bot is live, share it with us in the Community so others can try it out or get inspired.

Best,
The AgenticFlow Team :robot::sparkles:

2 Likes

Would be nice to have something like that for Instagram

I have tried but I cannot get reply on Telegram, even though my agent and my workflow can reply from AgennticFlow

Hi! Thanks for reaching out.

If your Agent and Workflow are replying inside AgenticFlow but not on Telegram, this issue usually happens due to one of the following reasons:

  1. The webhook connection to Telegram wasn’t set up successfully.
    Please double-check that your Telegram bot is properly connected to AgenticFlow with the correct token and webhook URL.
  2. The system prompt or agent behavior might be misconfigured.
    Can you share your System Prompt with us? It’ll help us better understand how your agent is expected to behave and troubleshoot more effectively.

Once we have those details, we’ll take a closer look for you!

i have the same problem. the webhook says: {“ok”:true,“result”:true,“description”:“Webhook was set”}
i can chat inside agentic flow and i can testrun the “send message to telegram” flow. but if i write something inside telegram nothing happens. the systemprompt is only this: “Du bist Marians Assistent, beantworte ihm alle Fragen indem Du das send_message_to_Telegram Tool nutzt.”
I did the complete tutorial, so i also changed the privacy settings inside telegram. any idea?

Hi,

Could you please go to the Agents section and check the chat history to see if any new chat sessions were created when you interacted with the bot on Telegram?

Alternatively, feel free to share your Agent ID, and we’ll help you debug it from our side.

well i am not sure, i tried it a lot of times, and and sometime it created something:


Agent.ID: eb28753d-dd28-4f6d-875a-b53138593605

Hi, Thanks for your message.

You can follow the step-by-step process in this video, starting at 29:40 – Telegram Bot Integration (Start-to-Finish):

:television: Watch here - https://www.youtube.com/watch?v=hz0r3obysmg&t=258s

We’ve checked on our end, and everything appears to be working normally. One possible reason you’re facing this problem is that your trigger step might not be properly connected.

Please double-check that your trigger is set up correctly.

Or, if it’s easier, you can record a short video showing how you’ve set up the Telegram bot and send it to us at support@agenticflow.ai — we’ll be happy to take a closer look and guide you from there.

Looking forward to helping you get it all working smoothly!

hey i already watched the video clip , its the same process and i still have the same problem. i send you an email

Hi,

We’ve reviewed it, and it looks like you missed one important step:

You need to connect the Telegram Bot to your workflow using the “Send Message to Telegram” action.

:wrench: How to create the Telegram connection within the “Send Message to Telegram” step:

  1. Go to the Connections tab in AgenticFlow.

  • Click “Create new connection”.
  • Choose Telegram as the connection type.
  • Paste your Telegram Bot Token.
  1. Then, in your workflow step, make sure to select the correct Telegram connection:

And the Chat ID part refers to the AgenticFlow thread ID, not the Telegram Chat ID

image

Hi Wendy, I’m finding Apple phone uses are not able to receive a reply with a Telegram bot. It works with Android uses just Apple uses not working.
Has anyone else had this issue?