deepeloper/tunneled-webhooks

Tunneled Webhooks

1.0.3 2023-10-06 08:08 UTC

This package is auto-updated.

Last update: 2024-04-06 09:25:33 UTC


README

Packagist version PHP from Packagist GitHub license GitHub issues Packagist

Donation

Runs tunneling service and registers temporary webhooks for workstation having no white IP by one command /path/to/php bin/run.php /path/to/config.php.

  • Implemented tunneling services: ngrok;
  • Implemented webhooks connectors: Telegram;
  • Implemented bots: Windbag.

You can add your own tunneling services, register and handle your own webhooks.

Compatibility

PHP 8.0

Installation

composer require deepeloper/tunneled-webhooks

Tunneling services

Download ngrok (and/or other tunneling services), sign up in service, get auth token and run service once /path/to/ngrok authtoken %YOUR_NGROCK_AUTH_TOKEN%.

Webhooks

Register Telegram bot and receive bot auth token.

Configuring local web server (nginx)

Add *.ngrok.io subdomains:

server {
    listen   127.0.0.1:80;
    server_name ~^(.*)\.ngrok\.io;

    ; This application www-directory
    root /path/to/www;
}

and restart nginx.

Application config

Copy "config.skeleton.php" to your own config file and put ngrok path & Telegram token to the new file:

    // ...
    'service' => [
        'class' => "\\deepeloper\\TunneledWebhooks\\Service\Ngrok",
        // CLI command to run service.
        // Modify path here:
        'command' => "/path/to/ngrok http 80",
        // ...
    ],
    
    'webhook' => [
        'Telegram' => [
            'Windbag' => [
                // ...
                // Telegram bot token.
                // Modify token here:
                'token' => "",
                // ...

Usage

Run tunneling service and bot

vendor/bin/tunneled-webhooks /path/to/config.php

Tunneling service will be started, Telegram webhook will be registered, and you could to start conversation with Telegram bot.

Run bot from CLI

vendor/bin/bot.windbag