Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack Command Example Doesn't Work #74

Closed
jaypeng2015 opened this issue Oct 19, 2017 · 5 comments
Closed

Slack Command Example Doesn't Work #74

jaypeng2015 opened this issue Oct 19, 2017 · 5 comments

Comments

@jaypeng2015
Copy link

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.

@mweagle
Copy link
Owner

mweagle commented 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.

@mweagle
Copy link
Owner

mweagle commented Oct 28, 2017

Hi @jaypeng2015 - I've updated the demo together with the upcoming 0.20.2 release. With the changes things appear to be back functioning.
slackbot

@jaypeng2015
Copy link
Author

Thanks @mweagle , I will test this again after the release.

@mweagle
Copy link
Owner

mweagle commented Nov 1, 2017

Hi @jaypeng2015 - I've released 0.20.2 & updated the sample at https://github.com/mweagle/SpartaSlackbot/blob/master/slack.go. Please LMK if this resolves the issue. Thanks!

@jaypeng2015
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants