pierce
(Pierce)
November 7, 2022, 4:25pm
11
Based on my experience building a Telegram bot slash command from the video walkthrough, I think a new trigger can be added to only listen to bot slash commands, instead of all messages.
I’ve opened up an issue here:
opened 04:23PM - 07 Nov 22 UTC
enhancement
help wanted
good first issue
trigger / source
**Describe the event source. What app is this for, and what event does the trigg… er correspond to?**
Currently we don't have a source specifically for responding to Telegram Bot slash commands.
As a Pipedream user, you can use the **New Updates** trigger, but it's clunky for building slash commands for Telegram Bots.
Here's an example of all of the steps you need to take currently to build a Telegram Bot that responds to a slash command:
https://www.youtube.com/watch?v=Tv2eT0CxoP4
Instead, it would be great if you could easily define a specific trigger to listen to all slash commands, or just a subset of slash commands.
**Please provide a link to the relevant API docs for the specific service / operation this trigger is tied to.**
* `getMyCommands` - [list all commands available to the current bot](https://core.telegram.org/bots/api#getmycommands).
The `getMyCommands` endpoint should be used to build an async options list for a `commands` prop.
Then you can detect if a particular incoming event is a slash command via the event's payload under the `entities` array`:

Pseudocode example:
```javascript
import telegramBot from '../telegramBot.app.mjs';
export default {
key: 'telegram-new-bot-command',
name: 'New Bot Command',
props: {
telegramBot,
commands: {
optional: true,
type: 'string[]',
async options() {
// list commands from the `getMyCommands` endpoint
}
}
}
async run(event) {
// detect if the event is a slash command using the `entites` attribute
// detect if there is a subset of commands defined in this.commands, and if this event is one of them
}
}
```
1 Like