I'm integrating slack
with jenkins
to use slash
commands and want to know if slash
commands have variables
What I want to do is something like this;
/this_word_should_be_in_the_url word
and the be able to use word
in the URL
the slash command will call.
On their page they have something like /weather 94070
Do I have access to the 94070
and somehow set is as a query
parameter for the URL.
Is this possible? Can't find any documentation of this.
Thanks.
Yes. You will have access to the word
as per the example that you mentioned.
So for example, if you have the following:
/this_word_should_be_in_the_url word
Then there will be an additional query parameter named text
that will contain everything else after the slash command. If you just have one parameter then it should be simple to just trim and use the text
query parameter but if you have multiple words and need to split them into something more meaningful, then you might have to use some regex or simple string split function.
It is documented at How do commands work. In this section they have provided the various query parameters that will get passed to your Slash Command External URL. For the weather example, the data posted as per the documentation is:
token=gIkuvaNzQIHg97ATvDxqgjtO
team_id=T0001
team_domain=example
channel_id=C2147483705
channel_name=test
user_id=U2147483697
user_name=Steve
command=/weather
text=94070
response_url=https://hooks.slack.com/commands/1234/5678
Notice the text
parameter in the above list.