# Slash command integration - Where are the parameters?

**URL:** <https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911>\
**Category:** Troubleshooting\
**Created:** [May 5, 2018, 1:03am UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911 "2018-05-05T01:03:52Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![harald](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/harald/32/2055_2.png) [@harald](https://forum.mattermost.com/u/harald)\
**Post date:** [May 5, 2018, 1:03am UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/1 "2018-05-05T01:03:52Z")

</div>

Hi,

I hope this is not a trivial and well known problem. I am testing MatterMost for 2 days only, but I would say I did my homework searching via Google in many places for an answer for my problem.

#### Summary

I cannot see/get my implicit parameters I should see as per [https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command](https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command) when using webtasks.  
E.g. the user\_name, user\_id, channel\_name etc.

Issue in one concise sentence

#### Steps to reproduce

MatterMost v4.9.1. Using docker-compose to run on a server I have. There’s no error coming out of the docker-compose logs.  
I’m using GET requests. POST did not work either.  
Here the exact webtask code:  
var express = require(‘express’);  
var Webtask = require(‘webtask-tools’);  
var bodyParser = require(‘body-parser’);  
var app = express();

```
app.use(bodyParser.json());

app.get('/', function (req, res) {
  //console.log(req.headers);
  let diceNumber = Math.floor(Math.random()*6+1);
  let whoAsked = req.query.user_name;
  res.status(200).send({"response_type": "in_channel", "text": `${whoAsked} rolled the dice and got a ${diceNumber}`});
});

module.exports = Webtask.fromExpress(app);

```

#### Expected behavior

I’d like to see the paramaters as per section 8 in [https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command](https://docs.mattermost.com/developer/slash-commands.html#custom-slash-command)  
When using Slack and the very same webtask, it worked immediately.

#### Observed behavior

`let whoAsked = req.query.user_name;`

should (for a GET request) show the user\_name. user\_id did not work either.

I get my text out on the channel. Except where the user name (or ID) should be, it’s “undefined”.

---

<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:** [May 5, 2018, 2:44am UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/2 "2018-05-05T02:44:51Z")

</div>

Hey @harald! Thanks for trying out Mattermost.

Do you see any error messages in **System Console \> Logs**? You may first need to set **System Console \> Logging \> Enable Webhook Debugging** to `true` and set **System Console \> Logging \> Console Log Level** to `DEBUG`.

---

<div class="post-metadata">

**Author:** ![harald](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/harald/32/2055_2.png) [@harald](https://forum.mattermost.com/u/harald)\
**Post date:** [May 6, 2018, 3:51am UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/3 "2018-05-06T03:51:13Z")

</div>

No error messages. All I can see in the logs which state that I executed a slash command is:

```
[2018/05/06 03:46:08 UTC] [DEBG] POST - /api/v4/commands/execute
[2018/05/06 03:46:08 UTC] [DEBG] Executing cmd=dice userId=sg6r65fnitnfpc3qodw4uyp38w

```

Is there a way to display the complete URL which is called for a slash command (incl. body)?

---

<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:** [May 6, 2018, 10:10pm UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/4 "2018-05-06T22:10:31Z")

</div>

Thanks @harald! Let me touch base with our engineers about this one.

---

<div class="post-metadata">

**Author:** ![harald](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/harald/32/2055_2.png) [@harald](https://forum.mattermost.com/u/harald)\
**Post date:** [May 7, 2018, 12:27pm UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/5 "2018-05-07T12:27:38Z")

</div>

Not sure this helps or is more confusing:  
Using Restify and NodeJS at work with its Mattermost server (testing at work, not installed by me), I could access the user\_name (and similar) parameters via req.body.user\_name when using POST.  
When using GET that did expectedly not work. However neither did req.query.user\_name.

I guess I’ll have to learn how to read the source code of Mattermost 🙂

---

<div class="post-metadata">

**Author:** ![harald](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/harald/32/2055_2.png) [@harald](https://forum.mattermost.com/u/harald)\
**Post date:** [May 7, 2018, 1:10pm UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/6 "2018-05-07T13:10:14Z")

</div>

Ok, found something which makes a lot of sense: bodyparser.json() is not the thing to use, but instead bodyparser.urlencoded(). With POST method this works as expected:

```
[...]app.use(bodyParser.urlencoded());

app.post('/', function (req, res) {
  let whoAsked = req.body.user_name; [...]

```

I still cannot GET work at all. Is it maybe totally broken? I have found no evidence that the parameters like user\_name etc. are in the URL. They always seem to be in the body.

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [May 8, 2018, 3:40pm UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/7 "2018-05-08T15:40:18Z")

</div>

Good to know the POST requests work. Do you have an example of what a GET request from Slack’s slash commands looks like?

---

<div class="post-metadata">

**Author:** ![harald](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/harald/32/2055_2.png) [@harald](https://forum.mattermost.com/u/harald)\
**Post date:** [May 9, 2018, 10:45am UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/8 "2018-05-09T10:45:44Z")

</div>

Here the complete and working code which does a GET request.  
Working for Slack. Not working for Mattermost:

```
var express = require('express');
var Webtask = require('webtask-tools');
var bodyParser = require('body-parser');
var app = express();

app.use(bodyParser.urlencoded());

app.get('/', function (req, res) {
  let diceNumber = Math.floor(Math.random()*6+1);
  let whoAsked = req.query.user_name;
    res.status(200).send({"response_type": "in_channel", "text": `${whoAsked} rolled the dice and got a ${diceNumber}`});
});

module.exports = Webtask.fromExpress(app);

```

Output in a Slack channel: `harald.kubota rolled the dice and got a 2`  
Output in a Mattermost channel: `undefined rolled the dice and got a 2`

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [May 10, 2018, 4:00pm UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/9 "2018-05-10T16:00:07Z")

</div>

Okay, so we’re not sending any of the query parameters that Slack does. Do you know if there’s a list of all possible query parameters somewhere? Or can you send us the full URL that Slack sent the request to in your example?

---

<div class="post-metadata">

**Author:** ![harald](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/harald/32/2055_2.png) [@harald](https://forum.mattermost.com/u/harald)\
**Post date:** [May 13, 2018, 11:48am UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/10 "2018-05-13T11:48:41Z")

</div>

Here is a simple one. Using http instead of https.

`[Sun May 13 2018 11:42:32 GMT+0000 (UTC)] "GET /?token=gBi77oq3GPr84sGhvOEx1qdH&team_id=TAJ3W83GQ&team_domain=apple-vs-oranges&channel_id=CAJHPQ9B6&channel_name=random&user_id=UAKM844JJ&user_name=harald.kubota&command=%2Fgettest&text=&response_url=https%3A%2F%2Fhooks.slack.com%2Fcommands%2FTAJ3W83GQ%2F362827359971%2FpbZRnmWvgxXMD1NRgvSTFPy9" "Slackbot 1.0 (+https://api.slack.com/robots)"`

Compare to Mattermost:

`[Sun May 13 2018 11:46:21 GMT+0000 (UTC)] "GET /" "Go-http-client/1.1"`

---

<div class="post-metadata">

**Author:** ![jesse](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/jesse/32/5168_2.png) [@jesse](https://forum.mattermost.com/u/jesse)\
**Post date:** [May 14, 2018, 3:01pm UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/11 "2018-05-14T15:01:26Z")

</div>

@harald, there was a bug with our implementation of slash commands that, when configured for GET, still sent the payload in the body instead of the querystring.

This will be fixed in the next release of Mattermost as per [https://mattermost.atlassian.net/browse/MM-10201](https://mattermost.atlassian.net/browse/MM-10201).

Sorry about this! I’d recommend sticking with POST until you can upgrade and get this fix.

---

<div class="post-metadata">

**Author:** ![hmhealey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/hmhealey/32/1915_2.png) [@hmhealey](https://forum.mattermost.com/u/hmhealey)\
**Post date:** [May 14, 2018, 3:13pm UTC](https://forum.mattermost.com/t/slash-command-integration-where-are-the-parameters/4911/12 "2018-05-14T15:13:56Z")

</div>

Thanks, Jesse. I wasn’t aware that we had a ticket to do that already. I was just about to file a new one
