Custom Message for Telegram Channel

Hi Everyone,

I have created a sample bot flow that collects user information through a conversation and successfully generates a filled PDF form. The flow works as expected when tested within the bot, and the PDF is generated successfully with the user’s details.

I then integrated the bot with the Telegram channel for testing. The PDF generation is still successful, and the API returns a valid download URL. However, the bot is not displaying the generated PDF URL to the user in the Message node on Telegram.

I have also configured a channel-specific message for Telegram, but I’m unsure how to correctly reference the dynamic variable (e.g., {{context.message}}) within the Telegram-specific message so that the generated PDF URL is displayed to the user.

Could you please guide me on the correct approach for passing and displaying dynamic variables such as the generated PDF URL in a Telegram channel-specific message? If there are any Telegram-specific limitations or recommended methods for sending a dynamically generated file URL, I would appreciate your guidance.

Can anyone guide me?

I used the below script for telegram channel message:

var pdfUrl = context.openAccountService.response.body.downloadUrl;

var message = {
text: “Your PDF has been generated successfully.”,
reply_markup: {
inline_keyboard: [
[
{
text: “:page_facing_up: Download PDF”,
url: pdfUrl
}
]
]
}
};

print(JSON.stringify(message));

the pdfUrl is not getting displayed while testing on telegram channel.

Hi Akash,

Thank you for sharing the script. Your approach is correct. The Telegram custom message should read the PDF URL returned by the service and use it as the destination of an inline button.

Please configure the Telegram response as Custom Javascript and use the following code:

var pdfUrl = context.openAccountService.response.body.downloadUrl;

var message = {
    text: "Your PDF has been generated successfully.",
    reply_markup: JSON.stringify({
        inline_keyboard: [[
            {
                text: "📄 Download PDF",
                url: pdfUrl
            }
        ]]
    })
};

print(JSON.stringify(message));

Please verify the following:

  1. The service response contains the URL at:
context.openAccountService.response.body.downloadUrl

  1. The downloadUrl value is not empty.

  2. The URL is a valid, publicly accessible HTTPS URL.

  3. The URL does not require authentication, VPN access, or an active browser session.

  4. Use straight quotes (" "), not curly quotes (“ ”).

  5. Use a normal emoji in the button text instead of Markdown image syntax.

  6. Configure the code under Telegram → Custom Javascript, not under the normal Text response.

  7. Save the bot and publish it again after making the change.

The original script used reply_markup as a nested object. In the tested configuration, serializing it with JSON.stringify allows Telegram to render the inline keyboard correctly.

The PDF URL will be assigned to the Download PDF button, so Telegram will display the button rather than the full URL as visible text. Clicking the button should open the generated PDF.

If the URL must be displayed as visible text instead, use a Telegram Text response:

Your PDF has been generated successfully.

Download it here:
{{context.openAccountService.response.body.downloadUrl}}

If the URL is stored at a different response path, use the path shown in the Service node’s debug response.

Sample Screenshot for reference**:**