sokil/php-viber-notifier

Allows to implement subscription on Viber's account and broadcast notifications to different groups of subscribed userss,

0.4 2020-05-15 20:31 UTC

This package is auto-updated.

Last update: 2021-04-24 15:10:39 UTC


README

Allows to implement subscription on Viber's account and broadcast notifications to different groups (roles) of subscribed users.

Total Downloads Build Status Coverage Status

Installation

composer require sokil/php-viber-notifier

WebHook

Viber informs server about events by webhook. It must be passed to Viber using API.

For Example:

#!/bin/sh

curl -XPOST -H 'X-Viber-Auth-Token: your-bot-api-token' "https://chatapi.viber.com/pa/set_webhook" -d '{"url": "https://server.com/chatbot/webhook/viber", "event_types": ["subscribed","unsubscribed","conversation_started"], "send_name": true, "send_photo" : true}'

Usage

To start sending notifications via Viber we need to create bot first.

When user joins Viber's chatbot, Viber sends postback request to our site with subscribed user details. Then we may send notifications to all subscribed users.

Users may have different roles, so we may broadcast different messages to different roles of users.

Subscribers repository

First we need to implement storage where subscribed Viber users and their roles will be stored.

Storage must implement SubscribersRepositoryInterface.

Viber chat bot client

If you already have convigured Viber bot in your project, just create adapter by implementing interface ViberClientInterface. If you have no chatbot in you project, use basic implementation ViberClient.