deepeloper/tunneled-webhooks

Tunneled Webhooks

1.1.0 2024-06-28 14:46 UTC

This package is auto-updated.

Last update: 2025-03-28 16:27:57 UTC


README

Packagist version PHP from Packagist GitHub license GitHub issues Packagist CI codecov

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.

  • Apache

According to ngrok docs in own config modify «service/command» value as /path/to/ngrok http --host-header=%LOCAL_HOST_NAME% 80.

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