# Issue slash commands from bot messages

**URL:** <https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949>\
**Category:** Troubleshooting\
**Created:** [October 19, 2018, 12:53pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949 "2018-10-19T12:53:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Herrner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/herrner/32/2445_2.png) [@Herrner](https://forum.mattermost.com/u/Herrner)\
**Post date:** [October 19, 2018, 12:53pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/1 "2018-10-19T12:53:14Z")

</div>

#### Summary

Is there a way to issue custom slash commands from bot messages?

#### Steps to reproduce

I created a custom slash command to perform GitLab-actions. It works just fine when I enter messages myself (like `/trigger issue new Testissue`), but if that command is issued from a bot (in this case, through an incoming webhook from zapier), it just prints the command w/o doing anything.

#### Expected behavior

I would expect the slash command to be performed, no matter where it comes from.

#### Observed behavior

The command isn’t performed, but pasted as a normal message.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [October 19, 2018, 3:07pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/2 "2018-10-19T15:07:00Z")

</div>

Hi @Herrner,

A workaround could be using custom slash commands: [https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command](https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command). Would this work?

---

<div class="post-metadata">

**Author:** ![Herrner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/herrner/32/2445_2.png) [@Herrner](https://forum.mattermost.com/u/Herrner)\
**Post date:** [October 22, 2018, 8:37am UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/3 "2018-10-22T08:37:49Z")

</div>

It is set up as a custom slash command already. The slash command itself is also working when entered directly - just not when entered by a bot. To me it seems that mattermost only looks for slash commands when messages are entered through the input field (before rendering them), and bot messages are rendered directly.

---

<div class="post-metadata">

**Author:** ![ThiefMaster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/thiefmaster/32/1476_2.png) [@ThiefMaster](https://forum.mattermost.com/u/ThiefMaster)\
**Post date:** [October 22, 2018, 7:46pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/4 "2018-10-22T19:46:39Z")

</div>

I would prefer to have an API to trigger slash commands over them being processed on normal messages sent through webhooks. I don’t want to have to bother with escaping such things (is that even possible right now?) when sending messages via the API.

IMHO slash commands are “in-band” for humans because having a separate edit box wouldn’t be convenient. But for bots they should very much be “out-of-band”.

---

<div class="post-metadata">

**Author:** ![jasonblais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jasonblais/32/720_2.png) [@jasonblais](https://forum.mattermost.com/u/jasonblais)\
**Post date:** [October 22, 2018, 9:19pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/5 "2018-10-22T21:19:05Z")

</div>

Thanks @Herrner, appreciate your feedback and the use case.

Similar to the note from @ThiefMaster, it may be trickier for integrations to escape such things. It is also not clear what “/away” should do if posted by a bot.

That said, I’m wondering if there are other approaches to consider.

Is the flow something:

1. Detect an event from a third-party service
2. Post a notification in Mattermost
3. Trigger a new issue based on the notification in step 2?

---

<div class="post-metadata">

**Author:** ![Herrner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/herrner/32/2445_2.png) [@Herrner](https://forum.mattermost.com/u/Herrner)\
**Post date:** [October 23, 2018, 12:33pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/6 "2018-10-23T12:33:45Z")

</div>

That’s the flow exactly. Zapier receives a specific E-Mail, posts that E-Mail as a bot to Mattermost and _should_ use that post as a slash command to create an issue on GitLab.

---

<div class="post-metadata">

**Author:** ![Herrner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/herrner/32/2445_2.png) [@Herrner](https://forum.mattermost.com/u/Herrner)\
**Post date:** [October 23, 2018, 2:02pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/7 "2018-10-23T14:02:51Z")

</div>

I fail at using the API for that, too. I’m getting “No command trigger found”-errors for everything I try. If our GitLab only had incoming email enabled - I wouldn’t need any of that then.

---

<div class="post-metadata">

**Author:** ![amy.blais](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/amy.blais/32/7481_2.png) [@amy.blais](https://forum.mattermost.com/u/amy.blais)\
**Post date:** [October 24, 2018, 5:55pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/8 "2018-10-24T17:55:09Z")

</div>

Would you like to [contribute this in the feature idea forum](https://mattermost.uservoice.com/forums/306457-general/) so it can be discussed, upvoted and considered for a [help wanted ticket](https://handbook.mattermost.com/contributors/contributors/help-wanted)?

Please include a link back to this Forum issue. If you’re interested in implementing, please say so and we’ll prioritize the review.

---

<div class="post-metadata">

**Author:** ![reftel](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/reftel/32/6214_2.png) [@reftel](https://forum.mattermost.com/u/reftel)\
**Post date:** [January 4, 2023, 1:05pm UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/9 "2023-01-04T13:05:33Z")

</div>

The “No command trigger found” can come for various reasons. In 7.5.2 (for instance), it is issued for the command being empty, not starting with a slash, or the channel ID being invalid (see [mattermost-server/command.go at v7.1.4 · mattermost/mattermost-server · GitHub](https://github.com/mattermost/mattermost-server/blob/v7.1.4/api4/command.go#L307-L310) )

---

<div class="post-metadata">

**Author:** ![agriesser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/agriesser/32/5644_2.png) [@agriesser](https://forum.mattermost.com/u/agriesser)\
**Post date:** [January 23, 2023, 5:10am UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/10 "2023-01-23T05:10:01Z")

</div>

Not 100% sure, but isn’t the GitLab integration bound to the user account? Not sure if a webhook has enough permissions to access the other integrations anyways, you might be in need for the use of a personal access token for your account, not sure if that makes a difference, just throwing out ideas here.

I’ve never worked with Zapier, but from what I read they should also be able to run more complex queries for the destination system, so if you give them your personal access token and authenticate with it on the [ExecuteCommand API call](https://api.mattermost.com/#tag/commands/operation/ExecuteCommand), you should be able to directly trigger the slash command in your name by skipping the webhook and the slash command parsing entirely.

---

<div class="post-metadata">

**Author:** ![Herrner](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/herrner/32/2445_2.png) [@Herrner](https://forum.mattermost.com/u/Herrner)\
**Post date:** [January 23, 2023, 9:03am UTC](https://forum.mattermost.com/t/issue-slash-commands-from-bot-messages/5949/11 "2023-01-23T09:03:20Z")

</div>

Thanks for all the suggestions. On a closer look, executing slash commands issued by bots will probably create more problems than I initially thought of.

I think the personal access token way w/ Zapier is probably the safest bet, but I think that we might essentially not allowed to user Zapier at all with our GitLab and Mattermost installations - I will probably go another route altogether using our self-hosted node red installation for this.
