Slack Command Example Doesn't Work
See original GitHub issueVersion: 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:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Thanks for the feedback @jaypeng2015 - things have changed quite a bit since the time I initially worked on that example. Fixes in progress. tyvm.
Tested on 0.20.3 and it went well. Thanks @mweagle, I will close this issue now.