From the course: Learn API Programming by Building a Telegram Bot

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Recognize slash commands

Recognize slash commands - PHP Tutorial

From the course: Learn API Programming by Building a Telegram Bot

Start my 1-month free trial

Recognize slash commands

- [Instructor] Most bots have multiple functions organized into some kind of menu. BotFather is a good example of this. We hit Start and get a list of options. We can type in a command but you'll notice that they're also clickable. That's because Telegram recognizes words preceded by a slash as something called an entity. We can see how it works in JSON Dump Bot. I'll go over and select it and then if I type in /hello we get an extra field called Entities. Inside Entities, we see a bot command that starts at position zero and has six characters. But bot command isn't the only kind of entity. In the API, we go to the message type and then to entities. The Entities parameter, in turn, contains an array of message entities. Click on that and you see all the entities that Telegram recognizes: @usernames, hashtags, email addresses, and so forth. We can test those out in JSON Dump Bot. I'll switch back to Telegram and…

Contents