Mattermost, Inc.

Issue slash commands from bot messages

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.

Hi @Herrner,

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

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.

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”.

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?

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.

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.

Would you like to contribute this in the feature idea forum so it can be discussed, upvoted and considered for a help wanted ticket?

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