The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/env perl
use strict;
use Log::Any qw< $log >;
Log::Any::Adapter->set('Stderr');
my $token = $ENV{TOKEN};
my $bot_url = $ENV{BOT_URL} || 'https://example.com/mybot';
plugin 'Bot::ChatBots::Telegram' => instances => [
[
'WebHook',
processor => \&processor,
register => 1,
token => $token,
unregister => 0,
url => $bot_url,
],
];
app->start;
sub processor { # tube-compliant
my $record = shift;
my $text = $record->{payload}{text};
print "$text\n";
$record->{send_response} = "you said: '$text'";
return $record; # follow on..
}