Coder Social home page Coder Social logo

driver-facebook's Introduction

BotMan

Latest Version on Packagist Build Status codecov Scrutinizer Code Quality Packagist StyleCI Slack Monthly Downloads

https://phppackagedevelopment.com

If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course.

About BotMan

BotMan is a framework agnostic PHP library that is designed to simplify the task of developing innovative bots for multiple messaging platforms, including Slack, Telegram, Microsoft Bot Framework, Nexmo, HipChat, Facebook Messenger and WeChat.

$botman->hears('I want cross-platform bots with PHP!', function (BotMan $bot) {
    $bot->reply('Look no further!');
});

If you want to learn how to create reusable PHP packages yourself, take a look at my upcoming PHP Package Development video course.

Documentation

You can find the BotMan documentation at https://botman.io.

Stand Alone Configuration

If you are installing Botman in a stand alone Laravel application, you can publish the configuration file with the following command:

php artisan vendor:publish --tag=config --provider="BotMan\BotMan\BotManServiceProvider"

Support the development

Do you like this project? Support it by donating

Contributing

Please see CONTRIBUTING for details.

0 1 2 3 4 5 6 7

Security Vulnerabilities

If you discover a security vulnerability within BotMan, please send an e-mail to Marcel Pociot at [email protected]. All security vulnerabilities will be promptly addressed.

License

BotMan is free software distributed under the terms of the MIT license.

driver-facebook's People

Contributors

aalmonte avatar apreiml avatar caleuanhopkins avatar ceyquem avatar crynobone avatar dive-michiel avatar drobee avatar filippotoso avatar flobauer avatar gulaandrij avatar hawkcraw avatar hugomartin89 avatar jeroen-g avatar johntiror avatar kenzouno1 avatar ker0x avatar mpociot avatar msonowal avatar richdynamix avatar simmatrix avatar stevenay avatar thedeadcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

driver-facebook's Issues

Something went wrong: (#11) Setting of Nested Persistent Menu has been deprecated for v8.0 and higher

  • BotMan Version: 2.6.1
  • PHP Version: 7.1.33
  • Messaging Service(s):

php artisan botman:facebook:AddMenu
Something went wrong: (#11) Setting of Nested Persistent Menu has been deprecated for v8.0 and higher

  • Cache Driver:

Description:

This is my configuration file

'persistent_menu' => [
    [
        'locale' => 'it_IT',
        'composer_input_disabled' => 'false',
        'call_to_actions' => [
            [
                'title' => 'Itinerari',
                'type' => 'nested',
                'call_to_actions' => [
                    [
                        'title' => 'Aree tematiche',
                        'type' => 'postback',
                        'payload' => 'Aree tematiche',
                    ],
                    [
                        'title' => 'Ultimi itinerari visti',
                        'type' => 'postback',
                        'payload' => 'Itinerari',
                    ],
                ],
            ],
            [
                'title' => 'Aiuto',
                'type' => 'postback',
                'payload' => 'Aiuto',
            ],
            [
                'title' => 'Preferenze',
                'type' => 'postback',
                'payload' => 'Preferenze',
            ],
        ],
    ],
    [
        'locale' => 'default',
        'composer_input_disabled' => 'false',
        'call_to_actions' => [
            [
                'title' => 'Journeys',
                'type' => 'nested',
                'call_to_actions' => [
                    [
                        'title' => 'Thematic Area',
                        'type' => 'postback',
                        'payload' => 'Aree tematiche',
                    ],
                    [
                        'title' => 'Last Journeys',
                        'type' => 'postback',
                        'payload' => 'Itinerari',
                    ],
                ],
            ],
            [
                'title' => 'Help',
                'type' => 'postback',
                'payload' => 'Aiuto',
            ],
            [
                'title' => 'Preferences',
                'type' => 'postback',
                'payload' => 'Preferenze',
            ],
        ],
    ],
],

Steps To Reproduce:

Can't add phone_number button

I want add hot line to button but not working. This only return tel: and empty number
Here is my code

$bot->reply(ButtonTemplate::create('Gọi điện cho tổng đài hotline')
            ->addButton(ElementButton::create('Hotline 1')->type('phone_number')->payload('+PHONE_NUMBER'))
            ->addButton(ElementButton::create('Hotline 2')->type('phone_number')->payload('+PHONE_NUMBER'))
        );

And Here is i'm debug buttons template

[2017-09-08 09:13:51] local.DEBUG: array (
  'type' => 'phone_number',
  'title' => 'Hotline 1',
  'url' => NULL,
)  
[2017-09-08 09:13:51] local.DEBUG: array (
  'type' => 'phone_number',
  'title' => 'Hotline 2',
  'url' => NULL,
)  

but template phone number of facebook is

 {
          "type":"phone_number",
          "title":"Call Representative",
          "payload":"+15105551234"
  }

Error installing driver "Facebook"

Full message when run command

$ php artisan botman:install-driver facebook
Installing driver "Facebook"
Using version ^1.10 for botman/driver-facebook

./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Package operations: 1 install, 0 updates, 0 removals

  - Installing botman/driver-facebook (1.10.0): 
Loading from cache


Package container-interop/container-interop is abandoned, you should avoid using it. Use psr/container instead.
Package zendframework/zend-diactoros is abandoned, you should avoid using it. Use laminas/laminas-diactoros instead.
Package zendframework/zend-escaper is abandoned, you should avoid using it. Use laminas/laminas-escaper instead.
Package zendframework/zend-http is abandoned, you should avoid using it. Use laminas/laminas-http instead.
Package zendframework/zend-loader is abandoned, you should avoid using it. Use laminas/laminas-loader instead.
Package zendframework/zend-log is abandoned, you should avoid using it. Use laminas/laminas-log instead.
Package zendframework/zend-servicemanager is abandoned, you should avoid using it. Use laminas/laminas-servicemanager instead.
Package zendframework/zend-stdlib is abandoned, you should avoid using it. Use laminas/laminas-stdlib instead.
Package zendframework/zend-uri is abandoned, you should avoid using it. Use laminas/laminas-uri instead.
Package zendframework/zend-validator is abandoned, you should avoid using it. Use laminas/laminas-validator instead.

Writing lock file
Generating optimized autoload files

Deprecation Notice: Class Twilio\TwiML\Voice\Echo_ located in ./vendor/twilio/sdk/src/Twilio/TwiML/Voice/Echo.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/Cellar/composer/1.9.2/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

Carbon 1 is deprecated, see how to migrate to Carbon 2.
https://carbon.nesbot.com/docs/#api-carbon-2
    You can run './vendor/bin/upgrade-carbon' to get help in updating carbon and other frameworks and libraries that depend on it.

> Illuminate\Foundation\ComposerScripts::postAutoloadDump

> @php artisan package:discover



In FacebookDriver.php line 92:

                                                       
  Trying to access array offset on value of type null  
                                                       



Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1


Installation failed, reverting ./composer.json to its original content.

Error installing driver "Facebook"

The cause of question may be facebook api spec that was changed.

https://github.com/botman/driver-facebook/blob/master/src/FacebookDriver.php#L92

Trying to access array offset on value of type null

  • BotMan Version: 2.6.1
  • PHP Version: 7.4.25
  • Messaging Service(s):
  • Cache Driver:
  • FacebookDriver: 1.11.0

Description:

Error when calling chatbot with FacebookDriver:

local.ERROR: Trying to access array offset on value of type null {"exception":"[object] (ErrorException(code: 0): Trying to access array offset on value of type null at .......vendor/botman/driver-facebook/src/FacebookDriver.php:516)

So in FacebookDriver:
$facebookResponse->getContent() return nothing
$facebookResponse->getStatusCode() = 500

protected function throwExceptionIfResponseNotOk(Response $facebookResponse)
{
    if ($facebookResponse->getStatusCode() !== 200) {
        $responseData = json_decode($facebookResponse->getContent(), true);
        throw new FacebookException('Error sending payload: '.$responseData['error']['message']);
    }
}

Steps To Reproduce:

Facebook driver tutorial

Handover Protocol

Does botman support facebook handover protocol? I have seen this code in driver-facebook but i don't know how to use this.

/** * Pass a conversation to the page inbox. * * @param IncomingMessage $message * @param $bot * @return Response */ public function handover(IncomingMessage $message, $bot) { return $this->http->post($this->facebookProfileEndpoint.'me/pass_thread_control?access_token='.$this->config->get('token'), [], [ 'recipient' => [ 'id' => $message->getSender(), ], 'target_app_id' => self::HANDOVER_INBOX_PAGE_ID, ]); }

If this is supported how do i use this? thank you

getUser not working

Hello,

I'm trying to use getUser to eventually get the user id, but I always have this error;

[2018-07-30 06:29:37] local.ERROR: Error sending payload: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api {"exception":"[object] (BotMan\\Drivers\\Facebook\\Exceptions\\FacebookException(code: 0): Error sending payload: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api at /Users/user/www/project/vendor/botman/driver-facebook/src/FacebookDriver.php:475) [stacktrace] #0 /Users/user/www/project/vendor/botman/driver-facebook/src/FacebookDriver.php(432): BotMan\\Drivers\\Facebook\\FacebookDriver->throwExceptionIfResponseNotOk(Object(Symfony\\Component\\HttpFoundation\\Response)) #1 /Users/user/www/project/vendor/botman/botman/src/BotMan.php(236): BotMan\\Drivers\\Facebook\\FacebookDriver->getUser(Object(BotMan\\BotMan\\Messages\\Incoming\\IncomingMessage)) #2 /Users/user/www/project/app/Http/Controllers/MessengerController.php(26): BotMan\\BotMan\\BotMan->getUser() #3 [internal function]: App\\Http\\Controllers\\MessengerController->handle(Object(Illuminate\\Http\\Request)) ...

I also tried using the dev-master of botman/driver-facebook, still the same result.

Anyone got an idea?

Thanks,
William

Framework repeatingly sending messages to Facebook Messenger

I've got the following problem: In some cases the framework does not stop sending messages to the Facebook messenger for some User. I know this problem, if there is an error in the code.

We could not find the problem during testing. I assumed the problem occurs if the user denies access to some information or tries to ignore the bot.

The Version in which the Problem was occuring was:

Laravel Framework 5.6.39
Botman Version 2.4.1

Facebook Driver
"name": "botman/driver-facebook",
"url": "https://github.com/botman/driver-facebook.git",
"url": "https://api.github.com/repos/botman/driver-facebook/zipball/8071f777388de7cde8122a340acdab01694d517b",
"homepage": "http://github.com/botman/driver-facebook",
"facebook",
"facebook messenger"
"botman/driver-facebook": "dev-master" (2.0-dev)

We have done an update to the system, the current version in test is:

Laravel Framework 5.6.39
Botman Version 2.5.0

Facebook Driver
"name": "botman/driver-facebook",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/botman/driver-facebook.git",
"reference": "a02096c5b9dafddc3353e8c5eff060fcb004985f"

If it is possible to get a hint for the cause of the problem it would be great.

Also if there is a setting to stop botman to repeatingly sending the same message over and over again this would be got to know.

undo botman:facebook:AddMenu

Hello ,
are there any way to undo php php artisan botman:facebook:AddMenu andphp artisan botman:facebook:AddStartButton
i wanna to remove the menu and the start button ?

Error sending payload: Unsupported get request. Object with ID 'XXX' does not exist

I am having an issue with the Facebook driver in production:

Error sending payload: Unsupported get request. Object with ID '1278886878901311' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api

This error doesn't surface in development and even in production, the bot seemed to work OK. I've had my entire team try it and everything looks ok. I am storing users first name, last name and PSID and also able to properly respond to the PSID's I've tested.

Yet my error log is full of thousands of errors like the one below.

My code is a simple conversation with $bot->getUser();

A stripped back version of my class:

class MyConversation extends BotMan\BotMan\Messages\Conversations\Conversation 
{
    public function conversation()
    {
        $question = Question::create('...')
            ->fallback("...")
            ->callbackId('...')
            ->addButtons([
                Button::create('Yes')->value('1'),
                Button::create('No thanks')->value('0')
            ]);

        $this->ask($question, function(Answer $answer) {

            $this->response = $this->getYesNoAnswer($answer);

            if ($this->response === true) {
               $this->saveResponse();
            }
        });
    }

    public function saveResponse()
    {
        $user = $this->bot->getUser();
        $id = $user->getId();
        $forename = $user->getFirstName();
        $surname = $user->getLastName();

        // Save id, forename and surname to DB.
    }
}

Essentially a simple conversation which runs a saveResponse() method which attempts to get the user via $this->bot->getUser();

Finally, the error:

[2018-12-17 20:40:05] production.ERROR: Error sending payload: Unsupported get request. Object with ID '1278886878901311' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api {"exception":"[object] (BotMan\\Drivers\\Facebook\\Exceptions\\FacebookException(code: 0): Error sending payload: Unsupported get request. Object with ID '1278886878901311' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api at /home/ashbot/vendor/botman/driver-facebook/src/FacebookDriver.php:505) [stacktrace] #0 /home/ashbot/vendor/botman/driver-facebook/src/FacebookDriver.php(462): BotMan\\Drivers\\Facebook\\FacebookDriver->throwExceptionIfResponseNotOk(Object(Symfony\\Component\\HttpFoundation\\Response)) #1 /home/ashbot/vendor/botman/botman/src/BotMan.php(236): BotMan\\Drivers\\Facebook\\FacebookDriver->getUser(Object(BotMan\\BotMan\\Messages\\Incoming\\IncomingMessage)) #2 /home/ashbot/app/Http/Conversations/Conversation.php(34): BotMan\\BotMan\\BotMan->getUser() #3 /home/ashbot/app/Http/Conversations/NintendoSwitchConversation.php(49): App\\Http\\Conversations\\Conversation->setFacebookUser(Object(BotMan\\BotMan\\BotMan)) #4 /home/ashbot/vendor/botman/botman/src/Traits/HandlesConversations.php(28): App\\Http\\Conversations\\NintendoSwitchConversation->run() #5 /home/ashbot/app/Http/Commands/NintendoSwitchCommand.php(15): BotMan\\BotMan\\BotMan->startConversation(Object(App\\Http\\Conversations\\NintendoSwitchConversation)) #6 [internal function]: App\\Http\\Commands\\NintendoSwitchCommand->handler(Object(BotMan\\BotMan\\BotMan), 'ENTER') #7 /home/ashbot/vendor/botman/botman/src/BotMan.php(478): call_user_func_array(Array, Array) #8 /home/ashbot/vendor/botman/botman/src/BotMan.php(408): BotMan\\BotMan\\BotMan->callMatchingMessages() #9 /home/ashbot/app/Http/Controllers/AshBotController.php(24): BotMan\\BotMan\\BotMan->listen() #10 [internal function]: App\\Http\\Controllers\\AshBotController->listener() #11 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array) #12 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('listener', Array) #13 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\AshBotController), 'listener') #14 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\\Routing\\Route->runController() #15 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(658): Illuminate\\Routing\\Route->run() #16 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #17 /home/ashbot/app/Http/Middleware/PageIdentifier.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #18 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): App\\Http\\Middleware\\PageIdentifier->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #19 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #20 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #21 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #22 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #23 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(68): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #24 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #25 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #26 /home/ashbot/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #27 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #28 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #29 /home/ashbot/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #30 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #31 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #32 /home/ashbot/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #33 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #34 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #35 /home/ashbot/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #36 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #37 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #38 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #39 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(660): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #40 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(635): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request)) #41 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(601): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route)) #42 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request)) #43 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request)) #44 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request)) #45 /home/ashbot/vendor/fideloper/proxy/src/TrustProxies.php(56): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #46 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #47 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #48 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #49 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #50 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #51 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #52 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #53 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #54 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #55 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #56 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #57 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #58 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure)) #59 /home/ashbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request)) #60 /home/ashbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request)) #61 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure)) #62 /home/ashbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request)) #63 /home/ashbot/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request)) #64 {main} "}

Thanks

How to get an attachmentId for an image

The Media Template code example for an image in the documentation is:

$bot->reply(MediaTemplate::create()
    ->element(MediaAttachmentElement::create('image')
        ->attachmentId('1543527005693234')
        ->addButton(ElementButton::create('Tell me more')
            ->type('postback')
            ->payload('Tell me more')
        )
        ->addButton(ElementButton::create('Documentation')
            ->url('https://botman.io/')
        )
    )
);

But how do I get an attachmentId for an image?

getText returns Value instead of text in Question Answer for quick replies

After "if $answer->isInteractiveMessageReply()",
the selected quick reply button's value can be accessed by $answer->getValue,
and the selected button's text should be accessed by $answer->getText. (this worked in the old version)
This is not the case with the new botman version. The $answer->getText returns the value of the button instead of the actual text.
So in a nutshell, both methods return the same value! for $answer->getValue!
@mpociot may you please look into that, thank you.

Bot not answering custom questions

Hi,

All the suddens some week ago the bot stopped to answer typed messages of customers.
Bot works fine only while using the FB menu, if i try to call the same actions typing is not working. Tinker is working fine.
I am using the latest botman and driver versions.

@mpociot I reopen this here hopefully is the right place, if you could help would be great.

Thanks!

Conversation with facebook driver not working

This is my case

This work
$this->ask('Email', function (Answer $answer) {
                $this->email = $answer->getText();
                $this->askPhone();
            });
This work
public function askPhone()
    {
        $this->ask('Phone', function (Answer $answer) {
            // Save result
            $this->phone = $answer->getText();
            $this->findOrder();
        });
    }
$orders = Order::where('email', $this->email)->where('phone', $this->phone)->orderBy('updated_at', 'DESC')->limit(5)->get();
        $list = ListTemplate::create()
            ->useCompactView()
        ;
        foreach ($orders as $order) {
            $list->addElement(
                Element::create('Chủ hóa đơn: ' . $order->name)
                    ->subtitle($order->order_key)
                    ->addButton(ElementButton::create('Xem chi tiết')
                        ->payload('tracker ' . $order->order_key)->type('postback'))
            );
        }
NOT WORK HERE
        $this->say($list);

Problem with BotMan Studio

Problem while installing facebook drive to BotMan Studio:

Installing driver "Facebook"
Using version ^1.2 for botman/driver-facebook


./composer.json has been updated


Loading composer repositories with package information


Updating dependencies (including require-dev)


Your requirements could not be resolved to an installable set of packages.



  Problem 1
    - Installation request for botman/driver-facebook ^1.2 -> satisfiable by botman/driver-facebook[1.2.0].
    - Conclusion: don't install botman/botman 2.1.2
    - Can only install one of: botman/botman[2.1.0, 2.0.1].
    - Can only install one of: botman/botman[2.1.0, 2.0.1].
    - Can only install one of: botman/botman[2.1.0, 2.0.1].
    - botman/driver-facebook 1.2.0 requires botman/botman ~2.1 -> satisfiable by botman/botman[2.1.0, 2.1.1, 2.1.2].
    - Conclusion: don't install botman/botman 2.1.1
    - Installation request for botman/botman (locked at 2.0.1, required as ~2.0) -> satisfiable by botman/botman[2.0.1].




Installation failed, reverting ./composer.json to its original content.


Successfully installed driver "Facebook"

This action was not allowed due to new data protection regulations in Europe

  • BotMan Version: 2.6.1
  • PHP Version: 7.4
  • Messaging Service(s): -
  • Cache Driver: Laravel

Description:

The following error is received when sending a private message to the Facebook user from Facebook page:

Error sending payload: (# 10) Diese Aktion wurde aufgrund neuer Datenschutzbestimmungen in Europa nicht gestattet. Sieh dir die Entwicklerdokumentation an, um mehr Infos zu erhalten. {"exception":"[object] (BotMan\Drivers\Facebook\Exceptions\FacebookException(code: 0): Error sending payload: (#10) Diese Aktion wurde aufgrund neuer Datenschutzbestimmungen in Europa nicht gestattet. Sieh dir die Entwicklerdokumentation an, um mehr Infos zu erhalten. at /www/htdocs/w01598d5/scout.zucher-duingen.de/Modules/Facebook/vendor/botman/driver-facebook/src/FacebookDriver.php:516)

Translation:

Error sending payload: (# 10) This action was not allowed due to new data protection regulations in Europe. Check out the developer documentation for more information. {"exception": "[object] (BotMan \ Drivers \ Facebook \ Exceptions \ FacebookException (code: 0): Error sending payload: (# 10) This action has not been allowed due to new data protection regulations in Europe. to get more information. at /www/htdocs/w01598d5/scout.zucher-duingen.de/Modules/Facebook/vendor/botman/driver-facebook/src/FacebookDriver.php:516)

Steps To Reproduce:

Try to send a private message to the Facebook user from Facebook page via Facebook Botman Driver.

Composer:

    "require": {
        "botman/botman": "2.6.1",
        "botman/driver-facebook": "1.11.0"
    }

Can not send message to facebook

Hello all,
Facebook disabled api version 2.6, and I upgrade to api version 3.0, but I can not send message to facebook, I only receive. Pls help me, Thanks!

Error installing driver "Facebook"

I install driver facebook and get error, help me to fix issue please, thanks!

php artisan botman:install-driver facebook

Installing driver "Facebook"
Do not run Composer as root/super user! See https://getcomposer.org/root for details

Using version ^1.9 for botman/driver-facebook

./composer.json has been updated

Loading composer repositories with package information

Updating dependencies (including require-dev)

Killed

Error installing driver "Facebook"

Call to undefined method Symfony\Component\HttpFoundation\Response::create() when adding webhook in facebook.

  • BotMan Version: 2.6.1
  • PHP Version: 8.1
  • Messaging Service(s): Facebook
  • Cache Driver: LaravelCache

Description:

Hi, im geting this error in laravel 9, how to handle it easiest way?

method create not exist, so should i make new class that extends Request with method create ?

I already tried to change all references from use Symfony\Component\HttpFoundation\Response;
to Illuminate\Http\Response (and Request) but this also not work.

curl -X GET "https://mydomain.com/botman?hub.verify_token=MySecretTokenFromDotENV&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"

Reponse:

Error: Call to undefined method Symfony\Component\HttpFoundation\Response::create() in file /var/www/nams/botman/driver-facebook/src/FacebookDriver.php on line 120

#0 /var/www/nams/botman/botman/src/Drivers/DriverManager.php(157): BotMan\Drivers\Facebook\FacebookDriver->verifyRequest()
#1 /var/www/nams/botman/botman/src/BotMan.php(542): BotMan\BotMan\Drivers\DriverManager::verifyServices()
#2 /var/www/nams/botman/botman/src/BotMan.php(421): BotMan\BotMan\BotMan->verifyServices()
#3 /var/www/nams/app/Http/Controllers/BotManController.php(40): BotMan\BotMan\BotMan->listen()
#4 /var/www/nams/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\Http\Controllers\BotManController->handle()...

Steps To Reproduce:

Install botman on laravel 9 from local repository (path)
change in composer/json dependencies to fit laravel 9
Try to connect to facebook like:

        $config = [
            'user_cache_time' => 720,

            'config' => [
                'conversation_cache_time' => 720 ,
            ],
            // Your driver-specific configuration
            'facebook' => [
                'token' => env('FACEBOOK_TOKEN'),
                'app_secret' => env('FACEBOOK_APP_SECRET'),
                'verification' => env('FACEBOOK_VERIFICATION'),
            ]
        ];
        $botman = app('botman');
        DriverManager::loadDriver(\BotMan\Drivers\Facebook\FacebookDriver::class);
        BotManFactory::create($config, new LaravelCache());
        $botman->listen();

try to get response for facebook by:
curl -X GET "https://mydomain.com/botman?hub.verify_token=MySecretTokenFromDotENV&hub.challenge=CHALLENGE_ACCEPTED&hub.mode=subscribe"

Use Facebook Driver without Laravel

Hello
Server php 7.0.2

<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

require_once 'vendor/autoload.php';

use BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
use BotMan\BotMan\Drivers\Facebook;


use BotMan\Drivers\Facebook\Extensions\ButtonTemplate;
use BotMan\Drivers\Facebook\Extensions\ElementButton;


$config = [
  'facebook' => [
    'token' => 'EAAHp16NF9xABAAZBZANt0u3gp9yZB4o9oJZCMu6d6TZCvtQfPGduvJL7yEgWKWkBS9SE1NZBG1LhNsDnPpp3mLb7MsIbzGV5m4ZBDo7GFN19uewTZBAmcZCXzBlp2Jhvhy0ZAdIfBtLEoQTbHfODD7L2JYry4sZA0mB0D5Wmxxxxxxxxx',
    'app_secret' => '9bee0490da15bxxxxxxx',
    'verification'=>'fb_bot',
  ]
];
// Load the driver(s) you want to use
DriverManager::loadDriver(\BotMan\Drivers\Facebook\FacebookDriver::class);
// Create an instance
$botman = BotManFactory::create($config);

$botman->hears('hello', function (BotMan $bot) {
	    $bot->reply('Hello yourself.');
	});

$botman->hears('m', function (BotMan $bot) {
  $bot->reply(ButtonTemplate::create('Do you want to know more about BotMan?')
    ->addButton(ElementButton::create('Забронировать столик')->type('postback')->payload('reserve'))
    ->addButton(ElementButton::create('Оформить быструю доставку')->url('http://scorini.mk.ua'))
    ->addButton(ElementButton::create('Перезвоните мне')->type('postback')->payload('callme'))
  );
  $bot->reply(ButtonTemplate::create('Do you want to know more about BotMan?')
    ->addButton(ElementButton::create('О нас')->type('postback')->payload('about'))
    ->addButton(ElementButton::create('Перезвоните мне')>type('postback')->payload('callme'))
    ->addButton(ElementButton::create('Чао!')->type('postback')->payload('chao'))
  );
});
$botman->fallback(function ($bot) {
    $bot->reply('Sorry, I did not understand these commands. Here is a list of commands I understand: ...');
});

// Start listening
$botman->listen();

?>

and have response

Response does not match challenge, expected value="620990634", received="\u003Cbr \/>\n\u003Cb>Parse er..."
Who can help with this error??

TODO: update documentation

Here I track what we should add to the Driver Documentation.

If you have any suggestions feel free to comment on this issue.

  • Quick reply button: #104

Adding new user information(field - division) for WORKPLACE (Facebook for companies)

  • BotMan Version: 2.4.1
  • botman/driver-facebook 1.11.0

Hi Marcel, can you please consider add one new field - "division" to request for get member community info

$fields = 'first_name,last_name,email,title,department,employee_number,primary_phone,primary_address,picture,link,locale,name,name_format,updated_time';

It would be great if this field was added into new version.

Bot facebook not respond

PHP 7.1
Botman installed with BotMan Studio
"botman/driver-facebook": "^1.3",

Hello, I'm having problems with my bot. (Facebook).
I was not able to validate though I read botman/botman#593 and changed the verifyRequest method to echo $ request->get('hub_challenge'); and I was able to validate.

However the return log
\Log::info('verification:'.$request->get('token'). 'hub_mode:'.$request->get('hub_mode').' - hub_verify_token: ' . $request->get('hub_verify_token') );

log laravel
[2017-11-15 21:17:26] local.INFO: verification:hub_mode:subscribe - hub_verify_token:
[2017-11-15 21:18:53] local.INFO: verification:hub_mode:subscribe - hub_verify_token:

it is always empty.
I do not know if this can have any relation, but my bot does not respond

Test with web bot tinker is working

routes/botman.php
############################

hears('Hi', function ($bot) { $bot->reply('Hello!'); }); $botman->hears('Start conversation', BotManController::class.'@startConversation'); ############################## Thanks for the help.

verifyRequest issue

Hey @mpociot @christophrumpel

I went over with more debug to figure out my issue, i am working on a base botman version with nothing, i see that the bot is receiving and logging the messages however is not sending replies.

I have done more and more debug i believe the script stops on FacebookDriver "verifyRequest" method, the response of that method is not returned because the IF is not satisfied, all the fields in the IF are empty.

The request however is not empty, heres the raw $request variable logged from inside "verifyRequest" method, seems fine to me.

[2019-02-22 19:40:55] local.INFO: POST /botman HTTP/1.1
Accept: /
Accept-Encoding: deflate, gzip
Content-Length: 320
Content-Type: application/json
Host: host.com
User-Agent: facebookexternalua
X-Hub-Signature: sha1=503beb8322ff16c837b3b99996b0e51d5ce5368b

{"object":"page","entry":[{"id":"163819740380232","time":1550864455383,"messaging":[{"sender":{"id":"1576733869023826"},"recipient":{"id":"163819740380232"},"timestamp":1550864454223,"message":{"mid":"fkc2KJuLMSeygQpagDXxvMkvSHHpsIkDt_hboDVObPYEpSLTx_KUHqa1dq8SUrJjTcoab5iDE3H62-_z3ZF90A","seq":528505,"text":"asd"}}]}]}

Is this due to changes on FB apis ?
Could you check this out? Would love to make this work again one day.

Thanks!

I can't attach PDF files to a reply

  • BotMan Version: v2.6.1
  • PHP Version: 7.4.12

Description:

this is the code:

<?php
use BotMan\BotMan\BotMan;
use BotMan\BotMan\Messages\Outgoing\OutgoingMessage;
use BotMan\BotMan\Messages\Attachments\File;

$botman = resolve('botman');

$botman->hears('Send PDF', function ($bot) {

    $attachment = new File('/pdf/example1.pdf', [
        'custom_payload' => true,
    ]);
    $message = OutgoingMessage::create('This is your PDF')
    ->withAttachment($attachment);
    $bot->reply($message);

});

It shows the message "This is your PDF" but without attachment, I tried with the full url, but doesn't work either. The pdf folder is located in the public folder. I'm using Facebook Driver.

Error when the bot subscribes to "message_echoes"

driver version: 1.0.2

If in the facebook bot developer console you subscribe the bot also to the "message_echoes", after the first message the bot will sto working since the driver does not support the echoes.

The error returned is:
Error sending payload: (#100) Tried accessing nonexisting field (first_name) on node type (Page) (500 Internal Server Error)

schermata 2017-09-09 alle 21 50 59

in order to reproduce simply subscribe the bot to "message_echoes" and than send a couple of messages, the bot will never answer the second message. Note: subscribing to a new field has a lag (few mins), keep in mind in case the bot will continue working.

How to setup the webhook url

What or where should I get the url to put in my messenger webhook... I don't get the documentation well ... controllers have routes , I really need to know how this

After that you can setup the webhook, which connects the Facebook application with your BotMan application. which is explained in this article

is done.

Webhook Url verification is returning with additional string

I am trying to verify my webhook url, however I am getting webhook_validation_error
Here is my code:

$config = [

   'facebook' => [
          'token' => 'page-token',
                'app_secret' => 'app-secret',
                'verification' => env('VERIFY_TOKEN')
     ]

 ];

   DriverManager::loadDriver(FacebookDriver::class);
    
   $botman = BotManFactory::create($config);   


   $botman->listen();

As noticed aboved I am getting additonal string added on the hub_challenge request. How will I able to solved this problem?

Can not install on laravel 5.6

Type error: Argument 1 passed to Illuminate\Routing\Router::sortMiddleware() must be an instance of Illuminate\Support\Collection, instance of Tightenco\Collect\Support\Collection given, called in /vendor/laravel/framework/src/Illuminate/Routing/Router.php on line 676

When using the regular optin button, there is no `user_ref` variable

Here is the webhook contents:

[2017-12-04 15:21:11] production.INFO: got something {"object":"page","entry":[{"id":"705168819692680","time":1512418869682,"messaging":[{"recipient":{"id":"705168819692680"},"timestamp":1512418869682,"sender":{"id":"1528804580544761"},"optin":{"ref":"WvL8Xkg1W2mwYBat"}}]}]}

and the error

[2017-12-04 15:21:11] production.ERROR: Undefined index: user_ref {"exception":"[object] (ErrorException(code: 0): Undefined index: user_ref at /vendor/botman/driver-facebook/src/FacebookDriver.php:314)

verifyRequest gets everything, but response is empty (when setting up webhook)

I can't seem to get the webhook between Messenger and Botman working. I tried it on localhost with ngrok USING THE EXACT SAME SCRIPT and it works, but I need it on my webserver.

I logged the hub_verify_token, hub_mode, and hub_challenge in the verifyRequest method and it gets the right token, hub_mode and hub_challenge, but I always get the "Response does not match challenge, expected value="468366090", received="" " error.

webhook_error
errorlog

I'm using it without BotMan Studio.

Message Added to an attachment does not go!

Consider the code below. The message "This is a video is not sent out, though the video is".
$attachment = new Video('video_url'); $message = OutgoingMessage::create('This is a Video')->withAttachment($attachment); $this->say($message);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.