Telegram advanced techniques

Using the template system

Feel free to use all the features of the Template system in Telegram step!

Processing system commands

Telegram bots have /commands, so add them in BotFather (using /setcommands) and create one scenario which triggers new objects from TMessageIn, and if there is no system commands in text field, the scenario sends an object to Router scenario.

That is essential. The best bot architecture includes only one scenario which triggers new TMessageIn objects.

Context-based architecture

Router scenario (it does not triggers by events, it is invoked) is routing messages, based on the value of the field context in TChat object.

Condition step (checking context) looks like:

Multi-context architecture

You can add as many fields in TChat structure (e.g. subcontext) and compose conditions on them. That is a way to create multi-context architecture.

Dealing with files, images and userpics

Step 1. Getting temporary file path

Call Telegram API-method getFile using Telegram step this way:

Then, save to a field temporary URL: https://api.telegram.org/file/bot_BOT_TOKEN_/{{API_response.file_path}}, where _BOT_TOKEN_ is token of your bot.

Step 2. Saving file to Directual

Use internal SDK method $D.fs.download (it can be applied both in SDK step and in Edit object step)