snippets_js
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" }
);