Search code examples
slack-apislack

creating a slack command without slash


There is this API with response of operator-city string.

https://nbhyb3s7db.execute-api.us-east-1.amazonaws.com/v1?mnumber=9819838466

I can check that it is working as expected. But when I create a command for this in slack, it does not work. It tries to visit the following URL that has extra slash / in it.

https://nbhyb3s7db.execute-api.us-east-1.amazonaws.com/v1?/mnumber=9819838466

How do I create a command without slash?


Update:

As per the docs, (Invoke external services with slash commands) response_type and text are the two essential keys those should be there in the reponse.

https://api.slack.com/custom-integrations

Is this correct or I am missing something?


Solution

  • You can easily build a test script that simulates slash commands from Slack. All you need is to send a HTTP POST request to your service with the correct parameters. A simple HTML page with a form will do the trick. Or you can use a more sophisticated PHP script, that will also be able to interpret the and output the result of your service in a nice way (that is what I am doing to test my services).

    Here is an example from the documentation how the POST request needs to look like:

    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