Skip to content

Type safe payload verification, validation, parsing and handling for Meta's Webhooks Objects, Fields, and Values event notifications

License

Notifications You must be signed in to change notification settings

pnmcosta/go-meta-webhooks

Repository files navigation

Go Meta Webhooks

This project provides a type safe payload verification, validation, parsing and handling for Meta's Webhooks Objects, Fields, and Values event notifications with the following features:

Install

go get github.com/pnmcosta/go-meta-webhooks

Import

import gometawebhooks "github.com/pnmcosta/go-meta-webhooks"

Use Cases

Wire-in this package with any HTTP server package, an example using Echo is provided in the samples directory submodule of this repository.

The example is an implementation of the InstagramHandler which covers supported Instagram field changes and messaging.

Scoped Handlers

You can granually implement each handler for scoped support instead. For example, to only handle InstagramMessageHandler event only instead:

package main

import gometawebhooks "github.com/pnmcosta/go-meta-webhooks"

var _ gometawebhooks.InstagramMessageHandler = (*handler)(nil)

type handler struct{}

func (h handler) InstagramMessage(ctx context.Context, sender, recipient string, sent time.Time, message Message){
    // TODO: implement message handling
}

func main(){
    handler := handler{}
    hooks, err := gometawebhooks.New(
        gometawebhooks.Options.InstagramMessageHandler(handler),
    )

    // TODO: implement HTTP routes see samples directory.
}

Unsupported Objects

Currently only Instagram Webhook objects and fields are explicitly supported, I plan on growing the package over time, however you can implement EntryHandler, ChangesHandler or MessagingHandler to handle events for unsupported objects.

About

Type safe payload verification, validation, parsing and handling for Meta's Webhooks Objects, Fields, and Values event notifications

Topics

Resources

License

Stars

Watchers

Forks

Languages