Download the PHP package sashalenz/viber-bot-api without Composer

On this page you can find all versions of the php package sashalenz/viber-bot-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package viber-bot-api

Viber Bot API

Viber Bot REST API SDK for Laravel — a typed HTTP client, webhook signature verification, and a nutgram-style inbound handler engine.

It is the reusable Viber engine (think nutgram/nutgram + its Laravel bridge): the package owns the protocol, while app-specific glue (persistence, CRM binding, notification channels) lives in your application.

Features

Requirements

Installation

The package is distributed via a private Composer registry. Add the repository, then require it:

Publish the config:

Set at least the token and sender name in your .env:

Configuration

All options live in config/viber-bot-api.php and are env-driven:

Env var Default Purpose
VIBER_BOT_TOKEN Public-account auth token (X-Viber-Auth-Token).
VIBER_BOT_API_URL https://chatapi.viber.com/pa/ API base URL.
VIBER_BOT_SENDER_NAME Bot Sender name (Viber caps it at 28 chars).
VIBER_BOT_SENDER_AVATAR Sender avatar URL.
VIBER_BOT_WEBHOOK_ROUTES_ENABLED true Register the webhook route.
VIBER_BOT_WEBHOOK_PREFIX viber-bot-api Route path prefix.
VIBER_BOT_WEBHOOK_KEY webhook Route path segment.
VIBER_BOT_WEBHOOK_DOMAIN Optional route domain.
VIBER_BOT_WEBHOOK_MIDDLEWARE Extra middleware (comma-separated).
VIBER_BOT_VERIFY_SIGNATURE true Enforce the HMAC signature check.

event_types (the events requested on set_webhook) is an array in the config file and defaults to all of message, subscribed, unsubscribed, conversation_started, delivered, seen, failed.

Outbound

send() / broadcast() return a typed SendMessageResponse (->status, ->message_token, …). A non-zero Viber status throws ViberBotApiException.

Message builders

Every builder implements MessageContract and validates its own Viber constraints in the constructor (throwing ViberBotApiException). Media is URL-based — pass a public https:// URL, not a binary upload.

Every builder also accepts the two send_message parameters common to all message types — trackingData (≤ 4096 chars, echoed back on the matching delivered / seen / message callbacks) and minApiVersion:

Keyboards

Account / webhook

⚠️ A Viber bot has exactly one webhook. setWebhook overwrites the previous one — there is no parallel delivery.

Users

Inbound

The package registers POST /{prefix}/{webhook_key} (default /viber-bot-api/webhook), guarded by the VerifyViberSignature middleware (HMAC-SHA256 of the raw body against your token). Prefix, domain, extra middleware, and on/off are configurable. The controller verifies the signature, parses the payload into a typed event, dispatches it through the container-bound Bot\Viber engine, and always responds 200 fast (Viber retries any non-200).

Registering handlers

Bot\Viber is bound as a singleton, so register handlers once — e.g. in a service provider's boot():

The first matching handler (in registration order) wins. Handlers receive the typed event plus the bot instance; $bot->reply(...) sends a send_message back to the user behind the current update. onText($pattern, ...) matches the message text against an anchored unicode regex.

conversation_started

This event is special: the user is not subscribed yet, so a real send_message is rejected. Return a MessageContract (or payload array) from the handler and the controller emits it inline in the HTTP 200 response, wrapped with the sender envelope:

Console commands

set-webhook defaults to the package webhook route URL when no argument is given, and prompts for confirmation unless --force is passed.

Typed request DTOs (optional)

If you prefer typed request payloads over the array/builder surface, use the RequestData DTOs:

Testing

Viber gotchas baked into the design

License

MIT. See LICENSE.md.


All versions of viber-bot-api with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/config Version ^11.0||^12.0||^13.0
illuminate/contracts Version ^11.0||^12.0||^13.0
illuminate/http Version ^11.0||^12.0||^13.0
illuminate/support Version ^11.0||^12.0||^13.0
spatie/laravel-data Version ^4.4
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sashalenz/viber-bot-api contains the following files

Loading the files please wait ...