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

[Wootric] Add support for Wootric webhooks #15

Closed
grokify opened this issue Mar 19, 2020 · 3 comments
Closed

[Wootric] Add support for Wootric webhooks #15

grokify opened this issue Mar 19, 2020 · 3 comments

Comments

@grokify
Copy link
Owner

grokify commented Mar 19, 2020

Requested features:

  • use colors for NPS: green (9-10), yellow (7-8), red (0-6)
  • support for custom formats without code / recompiling

Wootric Webhook Reference: http://docs.wootric.com/webhooks/#list-of-events-and-their-payload

@grokify
Copy link
Owner Author

grokify commented Mar 23, 2020

This is now supported for net/http and valyala/fasthttp HTTP engines.

An issue exists with AWS API Gateway + Lambda because the former cannot handle application/x-www-form-urlencoded requests without workarounds mentioned here:

Translating the request from application/x-www-form-urlencoded to JSON

The request comes in with a URL encoded body (Content-Type: application/x-www-form-urlencoded). Lambda does not understand this. Instead, Lambda expects input as JSON, and automatically converts that to an Object which becomes the event parameter. We'll use a template to translate the body into JSON. This translation occurs before the Lambda function runs.

In the Integration Request section we can configure how API Gateway makes a request to its integration, our Lambda function.

Go into Integration Request. Once there, expand Body Mapping Templates. Click Add mapping template and enter application/x-www-form-urlencoded. This lets us define a template to use for requests with this Content-Type:

@grokify
Copy link
Owner Author

grokify commented Mar 24, 2020

After implementing the AWS API Gateway Mapping Template recommendation, a snag in supporting Content-Type: application/x-www-form-urlencoded is that AWS API Gateway does not support URL query string parameters with this content type.

{
  "message":"When Content-Type:application/x-www-form-urlencoded, \
    URL cannot include query-string parameters (after '?'): \
    '/prod/webhook?inputType=wootric&outputType=glip&url=...'"
}

Heroku is confirmed to work.

More info on this requested here:

https://stackoverflow.com/questions/60825421/can-aws-api-gateway-support-application-x-www-form-urlencoded-with-query-strin

@grokify
Copy link
Owner Author

grokify commented Mar 25, 2020

Support for Wootric using net/http and valyala/fasthttp is considered done for now.

Two query string optionso ar available:

  • wootricFormatResponse (string) to supply a custom template
  • wootricSkipEmptyText (boolean) to enable skipping messages with empty text property

Open items for future consideration include:

  1. Support for application/x-www-form-urlencoded on Lambda will be considered in the future and is not specifically related to Wootric. For now, if Wootric is needed, use a hosted provider, e.g. Heroku.
  2. Enabling handlers to return a status code. Today to prevent a message from being sent, it can only return an error which results in a 500 status code which isn't correct since filtering is a correct client request behavior now.

@grokify grokify closed this as completed Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant