grokify / chathooks

Service to convert webhook messages to your favorite chat / team messaging format. Run transparently as a formatting webhook proxy.

Home Page:https://grokify.github.io/chathooks/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[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 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:

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

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.