Giter Club home page Giter Club logo

laravel-bitrix24-notification's Introduction

Laravel Bitrix24 notifications

This package makes it easy to send notifications using the Bitrix Bot Platform with Laravel.

Installation

You can install the package via composer:

composer require "pascallieverse/laravel-bitrix24-notification"

And finally publish the config file:

php artisan vendor:publish --provider="PascalLieverse\Bitrix24\Bitrix24ServiceProvider"

Setting up your Bitrix24 bot

  1. Inside bitrix24 navigate to: Extensions -> Applications -> Developer resources -> Add a chat bot -> Notify employees in the chat.
  2. Fill in the required fields to create the bot. The bot type should be "Chat bot, immediate response".
  3. Copy the "Webhook to call REST API" url and place this value inside your env file as BITRIX_WEBHOOK_URL.
  4. Copy the "Bot CLIENT_ID" and place this value inside your env as BITRIX_BOT_CLIENT_ID.

Usage

Now you can create a simple notification as follows:

<?php

namespace App\Notifications;

use Illuminate\Notifications\Notification;
use PascalLieverse\Bitrix24\Bitrix24Channel;
use PascalLieverse\Bitrix24\Bitrix24Message;

class BitrixNotice extends Notification
{

    /**
     * Create a new notification instance.
     */
    public function __construct()
    {
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param  mixed  $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [Bitrix24Channel::class];
    }

    /**
     * Get the message.
     *
     * @param  mixed  $notifiable
     * @return Bitrix24Message
     */
    public function toBitrix24($notifiable)
    {
        return (new Bitrix24Message())->text("Bitrix notification message!");
    }
}

The notification channel expects the user or chat ID to be passed. For example if the bitrix user ID is 1:

Notification::send(new Bitrix24Notifiable('1'), new BitrixNotice());

Or if the chat ID is 1:

Notification::send(new Bitrix24Notifiable('chat1'), new BitrixNotice());

License

MIT License (MIT). Freely redistributable product.

laravel-bitrix24-notification's People

Contributors

pascallieverse avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.