NAME

Bot::ChatBots::Messenger::WebHook - WebHook for Bot::ChatBots::Messenger

SYNOPSIS

use Mojolicious::Lite;
plugin 'Bot::ChatBots::Messenger',
   helper_name => 'messenger', # default is chatbots.messenger
   instances => [
      [
         WebHook => path => '/messenger/yadda-yadda-yadda',
         processor => \&process,
         verify_token => 'yadda-yadda-yadda',
      ]
   ];
app->start;

sub process {
   my $record = shift;
   # ...
   return $record;
}

DESCRIPTION

This module allows you to load a Mojolicious plugin for dealing with Facebook Messenger webhooks for a chatbot.

ACCESSORS

This module consumes role Bot::ChatBots::Role::WebHook, inheriting all the accessors. The accessors in the following subsections are added.

no_routes

boolean flag to avoid routes generation upon plugin import. Used during the "BUILD" process. Defaults to 0, meaning that the routes will be generated (both "install_route" in Bot::ChatBots::WebHook and "install_get_route").

verify_token

the verification token required by FaceBook to make sure your settings are accepted by your bot. You MUST set this or it will complain loudly upon calling "install_get_route".

METHODS

This module consumes role Bot::ChatBots::Role::WebHook and implements or overrides the methods in the following subsections.

BUILD

Called by Moo construction process. It uses "no_routes" to establish whether to call "install_route" in Bot::ChatBots::WebHook and "install_get_route" or not.

install_get_route

$obj->install_get_route(%args); # OR
$obj->install_get_route(\%args);

Install the additional GET route for Facebook verification process. See "validation_token", which MUST be available for this method to work.

normalize_record

my $r = $obj->normalize_record($input_record);

Modify $input_record in-place and return it, trying to put it in some standard shape. Which has not been standardized yet.

See "normalize_record" in Bot::ChatBots::Role::WebHook.

parse_request

my @updates = $obj->parse_request($c->req);

See "parse_request" in Bot::ChatBots::Role::WebHook.

BUGS AND LIMITATIONS

Report bugs either through RT or GitHub (patches welcome).

SEE ALSO

Foo::Bar.

AUTHOR

Flavio Poletti <polettix@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2016 by Flavio Poletti <polettix@cpan.org>

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.