# Telegram trigger - split command

**URL:** <https://community.n8n.io/t/telegram-trigger-split-command/3487>\
**Category:** Questions\
**Created:** [December 21, 2020, 10:52am UTC](https://community.n8n.io/t/telegram-trigger-split-command/3487 "2020-12-21T10:52:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcondy](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/marcondy/32/2798_2.png) [@marcondy](https://community.n8n.io/u/marcondy)\
**Post date:** [December 21, 2020, 10:52am UTC](https://community.n8n.io/t/telegram-trigger-split-command/3487/1 "2020-12-21T10:52:25Z")

</div>

Hello,

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

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [December 21, 2020, 11:03am UTC](https://community.n8n.io/t/telegram-trigger-split-command/3487/2 "2020-12-21T11:03:04Z")

</div>

Hey @marcondy!

You can use the [replace()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) method to replace `!p` in incoming text and pass it on the [IF](https://docs.n8n.io/nodes/n8n-nodes-base.if/#if) node or the [Switch](https://docs.n8n.io/nodes/n8n-nodes-base.switch/#switch) node to check for the conditions.

You can use the replace() method either in the [Function](https://docs.n8n.io/nodes/n8n-nodes-base.function/#function) node or in the Expression Editor.

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![harshil1712](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/harshil1712/32/1374_2.png) [@harshil1712](https://community.n8n.io/u/harshil1712)\
**Post date:** [December 21, 2020, 11:21am UTC](https://community.n8n.io/t/telegram-trigger-split-command/3487/3 "2020-12-21T11:21:32Z")

</div>

@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`.

---

<div class="post-metadata">

**Author:** ![marcondy](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/marcondy/32/2798_2.png) [@marcondy](https://community.n8n.io/u/marcondy)\
**Post date:** [December 21, 2020, 8:14pm UTC](https://community.n8n.io/t/telegram-trigger-split-command/3487/4 "2020-12-21T20:14:53Z")

</div>

Thank you !
