Telegram @ mention trigger

Before I build this myself, I am a little surprised there isnt a trigger for this already. Or maybe it’s not a trigger but rather a setting within a trigger that I am missing.

Here is what I’m thinking:

When you @ mention the telegram bot
The trigger activates

Simple as that.

Currently the trigger only activates when you directly message a bot (or reply to a bot in a chat).

Am I missing this functionality? If not I will look into how complicated it is to add, and share with the community.

Update:

This is already possible, I just need to

  • (all message types)
    (add a function node)
    Filter only mentions of it’s username

Will update here how it goes.

UPDATE: you need to change the bots privacy settings in botfather to allow group invite/messages.

It worked great. FYI, this is the code i used in the code node after the *message trigger in case others want to do this too:

const message = items[0].json.message;
if (message.entities) {
const mention = message.entities.find(e => e.type === ‘mention’);
if (mention) {
const mentionedUsername = message.text.slice(mention.offset + 1, mention.offset + mention.length);
if (mentionedUsername.toLowerCase() === ‘bot_username’) {
return items;
}
}
}
return ;

1 Like