webhook-proxy-go

command module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2018 License: MIT Imports: 37 Imported by: 0

README

Chathooks - A chat webhook proxy

Build Status Go Report Card Docs License

Chathooks is a service that maps webhook posts from different services to message platforms such as Glip and Slack's inbound webhook service. It uses handlers to convert inbound messages to the CommonChat canonical message format which are then sent via message platform adapters. This is useful because many services with outbound webhooks need to be formatted before they can be consumed by an inbound webhook. This proxy service does the conversion so you don't have to. Another use case is conversion of inbound messages so a message formatted for Slack inbound webhooks can be delivered to a Glip inbound webhook.

It is easy to add additional inbound webhook handlers and outbound webhook adapters by using the adapters.Adapter and handlers.Handler interfaces.

Chathooks currently supports two HTTP server engines.

Conversion of the following webhook message formats to Glip inbound webhooks include:

Outbound Webhook Formats supported:

  1. AppSignal
  2. Apteligent/Crittercism
  3. Circle CI
  4. Codeship
  5. Confluence
  6. Datadog
  7. Desk.com
  8. Enchant
  9. GoSquared
  10. Heroku
  11. Librato
  12. Magnum CI
  13. Marketo
  14. OpsGenie
  15. Papertrail
  16. Pingdom
  17. Raygun
  18. Runscope
  19. Semaphore CI, Deploy
  20. StatusPage
  21. Travis CI
  22. Userlike
  23. VictorOps

Inbound Webhook Format supported:

  • Slack (inbound message format) - text only

Note: Slack inbound message formatting is for services sending outbound webhooks using Slack's inbound webhook message format, which can be directed to Glip via this proxy.

Example Webhook Message from Travis CI:

Installation

$ go get github.com/grokify/webhookproxy

Usage

Starting the Service using FastHTTP

Start the service in server.go.

  • To adjust supported handlers, edit server.go to add and remove handlers.

Start the service with the following.

Note: The emoji to URL is designed to take a icon_emoji value and convert it to a URL. EmojiURLFormat is a fmt format string with one %s verb to represent the emoji string without :. You can use any emoji image service. The example shows the emoji set from github.com/wpeterson/emoji forked and hosted at grokify.github.io/emoji/.

Creating the Glip Webhook
  1. create a Glip webhook
  2. use webhook URL's GUID to create the proxy URL as shown below
  3. use the proxy URL in your outbound webhook service
Query Parameter Required? URL
inputType required An handler service like marketo
outputType required An adapter service like glip
url required A webhook URL or UID, e.g. 11112222-3333-4444-5555-666677778888
token optional Must be included if service is configured to use auth tokens

The webhook proxy URLs support both inbound and outbound formats. When available, these should be represented in the handler key.

To create the Glip webhook and receive a webhook URL do the following:

Add the Webhook Integration

At the top of any conversation page, click the Settings gear icon and then click Add Integration.

Select the Glip Webhooks integration.

Get the Webhook URL

Once you get the URL, the proxy URL is created by appending the GUID (e.g. 1112222-3333-4444-5555-666677778888) to the proxy URL base, hooks?inputType=slack&outputType=glip (e.g. https://glip-proxy.example.com/hooks?inputType=slack&outputType=glip&url=1112222-3333-4444-5555-666677778888). Use the proxy URL in the app that is posting the Slack webhook and the payload will be sent to Glip.

Example Requests

Most of the time you will likely either:

  • use the proxy URL in an outbound webhook service that supports the Slack format or
  • use a client library

The following examples are provided for reference and testing.

Using application/json
$ curl -X POST \
  -H "Content-Type: application/json" \
  -d '{"username":"ghost-bot", "icon_emoji": ":ghost:", "text":"BOO!"}' \
  "http://localhost:8080/hooks?inputType=slack&outputType=glip&url=11112222-3333-4444-5555-666677778888"
Using application/x-www-form-urlencoded
$ curl -X POST \
  --data-urlencode 'payload={"username":"ghost-bot", "icon_emoji": ":ghost:", text":"BOO!"}' \
  "http://localhost:8080/hooks?inputType=slack&outputType=glip&url=11112222-3333-4444-5555-666677778888"
Using multipart/form-data
$ curl -X POST \
  -F 'payload={"username":"ghost-bot", "icon_emoji": ":ghost:", text":"BOO!"}' \
  "http://localhost:8080?hooks?inputType=slack&outputType=glip&url=11112222-3333-4444-5555-666677778888"
Using Community Ruby SDK

This has been tested using:

require 'slack/poster'

url = 'http://localhost:8080?inputType=slack&outputType=glip&url=11112222-3333-4444-5555-666677778888'

opts = {
	username: 'Ghost Bot [Bot]',
	icon_emoji: ':ghost:'
}

poster = Slack::Poster.new url, opts
poster.send_message 'BOO!'

Notes

Chathooks is built using:

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL