Telegram trigger - split command


I am trying to setup a bot that is triggered in group chat by “!p {input}” , {input} is user defined, I can’t find a way to separate “!p” from {input} so I can use that input to query database.
Let me give you an example, user wants to know the price of bitcoin, user types !p btc, boot looks up price of btc. but if user changes btc to something else I want the bot to understand new variable.

Thank you

Hey @marcondy!

You can use the replace() method to replace !p in incoming text and pass it on the IF node or the Switch node to check for the conditions.

You can use the replace() method either in the Function node or in the Expression Editor.

Hope this helps :slightly_smiling_face:

@marcondy below is the workflow that might help

The expression {{$node["Telegram Trigger"].json["message"]["text"].replace('!p ','')}} replaces !p with an empty string. So if a user sends !p btc, in the Switch node it will only check for btc.

1 Like

Thank you !

1 Like