[Wootric] Add support for Wootric webhooks
grokify opened this issue · comments
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
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 JSONThe 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:
- https://blog.summercat.com/using-aws-lambda-and-api-gateway-as-html-form-endpoint.html
- https://intellipaat.com/community/16734/post-url-encoded-form-to-amazon-api-gateway
- https://www.reddit.com/r/aws/comments/cpx6w4/how_do_you_configure_xwwwformurlencoded_in_api/
- https://stackoverflow.com/questions/32057053/how-to-pass-a-params-from-post-to-aws-lambda-from-amazon-api-gateway
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:
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 templatewootricSkipEmptyText
(boolean) to enable skipping messages with emptytext
property
Open items for future consideration include:
- 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. - Enabling handlers to return a status code. Today to prevent a message from being sent, it can only return an
error
which results in a500
status code which isn't correct since filtering is a correct client request behavior now.