Coder Social home page Coder Social logo

viber-driver-botman's Introduction

BotMan Viber Driver

Connect Viber with BotMan

Installation & Setup

First you need to pull in the Viber Driver.

composer require kononovspb/botman-viber-driver

Then load the driver before creating the BotMan instance (only when you don't use BotMan Studio):

DriverManager::loadDriver(\Kononovspb\Drivers\Viber\ViberDriver::class);

// Create BotMan instance
BotManFactory::create($config);

This driver requires a valid and secure URL in order to set up webhooks and receive events and information from the chat users. This means your application should be accessible through an HTTPS URL.

To connect BotMan with your Viber Bot, you first need to follow the official guide to create your Viber Bot and an access token.

Once you have obtained the access token, place it in your .env file like VIBER_TOKEN=YOUR-VIBER-TOKEN-HERE. There it gets automatically loaded to your config/botman/viber.php file.

If you don't use BotMan Studio, add these line to $config array that you pass when you create the object from BotManFactory.

'viber' => [
    'token' => 'YOUR-VIBER-TOKEN-HERE',
]

Register Your Webhook

To let your Viber Bot know, how it can communicate with your BotMan bot, you have to register the URL where BotMan is running at, with Viber.

You can do this by sending a POST request to this URL:

https://chatapi.viber.com/pa/set_webhook

This POST request needs parameter called url with the URL that points to your BotMan logic / controller. If you use BotMan Studio it will be: https://yourapp.domain/botman. HTTPS is a must, because of security reasons.

{
   "url":"https://my.host.com",
   "event_types":[
      "delivered",
      "seen",
      "failed",
      "subscribed",
      "unsubscribed",
      "conversation_started"
   ],
   "send_name": true,
   "send_photo": true
}

You can read about other fields in the request in the official documentation.

Instead of manually sending the request to Viber you can use a console command to register your Webhook.

php artisan botman:viber:register

viber-driver-botman's People

Contributors

adellantado avatar theardent avatar polyskalov avatar kononovspb avatar krogla avatar vladdevops avatar sasha-ch 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.