Skip to main content
Novu’s Go SDK provides simple, yet comprehensive notification management, and delivery capabilities through multiple channels that you can implement using code that integrates seamlessly with your Go application. Explore the source code on GitHub

Installation

go get github.com/novuhq/novu-go

Usage

  • US Region
  • EU Region
package main

import (
	"context"
	novugo "github.com/novuhq/novu-go"
	"github.com/novuhq/novu-go/models/components"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	s := novugo.New(
		novugo.WithSecurity(os.Getenv("NOVU_SECRET_KEY")),
	)

	res, err := s.Trigger(ctx, components.TriggerEventRequestDto{
		WorkflowID: "workflow_identifier",
		Payload: map[string]any{
			"comment_id": "string",
			"post": map[string]any{
				"text": "string",
			},
		},
		Overrides: map[string]map[string]any{
			"email": map[string]any{
				"bcc": "no-reply@novu.co",
			},
		},
		To: components.CreateToSubscriberPayloadDto(
			components.SubscriberPayloadDto{
				SubscriberID: "subscriber_uniuqe_identifier",
				FirstName: "Albert",
				LastName: "Einstein",
				Email: "albert@einstein.com",
			},
		),
	}, nil)
	if err != nil {
		log.Fatal(err)
	}
	if res.TriggerEventResponseDto != nil {
		// handle response
	}
}
I