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.
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:
Detect an event from a third-party service
Post a notification in Mattermost
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.
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, you should be able to directly trigger the slash command in your name by skipping the webhook and the slash command parsing entirely.
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.