Skip to main content

Telegram

This package makes creating Telegram bots so simple!

Official Websitehttps://telegram.org/
Tagsmessagingbot

Credential configuration

To configure this credential, you need the token from your Telegram Bot. You can create a bot or create a token for an existing bot using Telegram's BotFather.

Optionally, you can set any of the extra config parameters you can see here.

Here is an example of a filled credential configuration form in YepCode:

Telegram Snippets available in Editor

note

The title is the triggering text for YepCode to autocomplete the script.

Integration

New integration from credential
const telegram = yepcode.integration.telegram('credential-slug');
New integration from plain authentication data
const { Bot } = require('grammy');

const telegram = new Bot("your-bot-token");

Set Webhook

You may want to receive messages to your bot using a webhook to a YepCode process which handles them. You can do this using this snippet:

Set webhook
await telegram.api.setWebhook("webhook-url");

You can also set the webhook by doing a request to this URL with your bot token and your webhook URL:

https://api.telegram.org/bot<your-bot-token>/setWebhook?url=https://cloud.yepcode.io/api/<your-team-name>/webhooks/<processId>

Set Bot Commands

Set bot commands
await telegram.api.setMyCommands([
{ command: "commandName", description: "Command description" },
{ command: "commandName", description: "Command description" },
]);

Send Message

Send message
await telegram.api.sendMessage(chatId, "message-content");

Send HTML Message

Send HTML message
await telegram.api.sendMessage(
chatId,
"<b>Hi</b> from <a href="https://yepcode.io">YepCode</a>!",
{ parse_mode: "HTML" }
);

Send Markdown Message

Send Markdown message
await telegram.api.sendMessage(
chatId,
"*Hi* from [YepCode](https://yepcode.io)\\!",
{ parse_mode: "MarkdownV2" }
);