question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slack Command Example Doesn't Work

See original GitHub issue

Version: 0.20.1

I am trying to create a slack command by following: http://gosparta.io/docs/apigateway/example3/, but there are some things break:

  • Should return on error There a several if err != nil {...} which send 500 error to the client. However the function doesn’t stop after doing that but still executes the rest lines.

  • Missing Content Type

    The last step of this function

    w.Write(responseBody)
    

    Send the content as text. Requires w.Header().Set("Content-Type", "application/json") to make it work.

  • Custom Event Type The whole part doesn’t work for me. What I received from API Gateway is already JSON, not a form string, so I created a new struct:

    type slashCommandJSONBody struct {
      Token       string `json:"token"`
      TeamID      string `json:"team_id"`
      TeamDomain  string `json:"team_domain"`
      ChannelID   string `json:"channel_id"`
      ChannelName string `json:"channel_name"`
      UserID      string `json:"user_id"`
      UserName    string `json:"user_name"`
      Command     string `json:"command"`
      Text        string `json:"text"`
      ResponseURL string `json:"response_url"`
    }
    

    And then changed body to Body slashCommandJSONBody json:“body”`` to make it work.

  • Integration mapping breaks on empty fields If the command has no text, e.g. /weather, the original body will be something like “user_id=U12345&text=&command=/weather”, then the api gateway will just return 500 error. From the source code I found this ## Ref: https://gist.github.com/ryanray/668022ad2432e38493df, and from that link I can see someone else was having the same issue. As long as I put text in, everything work fine.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mweaglecommented, Oct 19, 2017

Thanks for the feedback @jaypeng2015 - things have changed quite a bit since the time I initially worked on that example. Fixes in progress. tyvm.

0reactions
jaypeng2015commented, Nov 13, 2017

Tested on 0.20.3 and it went well. Thanks @mweagle, I will close this issue now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Enabling interactivity with Slash Commands - Slack API
Understanding the structure of Slash Commands. Let's look at an example Slash Command, for a simple app that stores a list of to-do...
Read more >
Troubleshoot slash command on Slack - Tettra Support
The Tettra slash command isn't working correctly. For example, the /tettra option does not show up in your Slack app.
Read more >
Slack Slash commands - Not working in private channels or ...
The solution was for the creator of the webhook to edit it (not the code, just the webhook) and set it by default...
Read more >
slash commands result in `dispatch_failed` · Issue #579 - GitHub
Description I'm using a localtunnel type service to send commands to my bot But on sending /commands, I just get an error message...
Read more >
Bolt for Python - Slack Platform Developer Tools
Within your listener function, say() is available whenever there is an associated conversation (for example, a conversation where the event or action which ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found