Giter Club home page Giter Club logo

laravel-novu-notifications's Introduction

Software License Laravel Version Requirements

Novu - Laravel Notification Channel

This package makes it easy to send notifications using Novu

class InvoicePaidNotification extends Notification
{
    // Trigger a specific notification event
    public function toNovuEvent($notifiable)
    {
        return NovuMessage::create('workflow_1234')
            ->addVariable('invoice_id', $this->invoice->id)
            ->toSubscriberId('123456789');
    }
}

Contents

Installation

The Novu notification channel can be installed easily via Composer:

$ composer require xcoorp/laravel-novu-notifications

Usage

In order to send a notification via the Novu channel, you'll need to specify the channel in the via() method of your notification:

use NotificationChannels\Novu\NovuChannel;

public function via($notifiable)
{
    return [
        NovuChannel::class
    ]
}

API Overview

Novu Message

Namespace: NotificationChannels\Novu\NovuMessage

The NovuMessage class encompasses an entire message that will be sent to the Novu API.

  • static create(?string $workflowId) Instantiates and returns a new NovuMessage instance, optionally pre-configuring it with the workflow id
  • workflowId(string $workflowId) Set the workflowId of the message (Your novu workflow trigger id)
  • to(array $to) Array of recipient information like subscriberId, phone, etc...
  • toSubscriber(string $subscriberId) Set the subscriberId of the recipient
  • variables(array $variables) Set the variables (payload) of the message. Those are your novu event variables
  • addVariable(string $key, $value) Add a single variable to the message
  • toArray() Returns the data that will be sent to the Novu API as an array

Testing

Functionality of this package is tested with Pest PHP. You can run the tests with:

composer test

Code of Conduct

In order to ensure that the community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review the security policy on how to report security vulnerabilities.

License

The MIT License (MIT). Please see License File for more information.

laravel-novu-notifications's People

Contributors

toitzi avatar github-actions[bot] avatar

Watchers

Daniel Niazmand avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.