christophrumpel / bcwp-laraconeu-chatbot

This the code for the Laracon EU chatbot from my book "Build Chatbots with PHP"
5 stars 3 forks source link

FAQ Location on Facebook: Message cannot be empty, must provide valid attachment or text #4

Closed andreshg112 closed 6 years ago

andreshg112 commented 6 years ago

I'm getting the error below.

[2018-08-22 05:35:50] local.ERROR: Error sending payload: (#100) Message cannot be empty, must provide valid attachment or text {"exception":"[object] (BotMan\\Drivers\\Facebook\\Exceptions\\FacebookException(code: 0): Error sending payload: (#100) Message cannot be empty, must provide valid attachment or text at /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/driver-facebook/src/FacebookDriver.php:503)
[stacktrace]
#0 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/driver-facebook/src/FacebookDriver.php(398): BotMan\\Drivers\\Facebook\\FacebookDriver->throwExceptionIfResponseNotOk(Object(Symfony\\Component\\HttpFoundation\\Response))
#1 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/BotMan.php(638): BotMan\\Drivers\\Facebook\\FacebookDriver->sendPayload(Array)
#2 [internal function]: BotMan\\BotMan\\BotMan->BotMan\\BotMan\\{closure}(Array)
#3 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/mpociot/pipeline/src/Pipeline.php(114): call_user_func_array(Object(Closure), Array)
#4 [internal function]: Mpociot\\Pipeline\\Pipeline->Mpociot\\Pipeline\\{closure}(Array)
#5 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/mpociot/pipeline/src/Pipeline.php(102): call_user_func_array(Object(Closure), Array)
#6 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/Middleware/MiddlewareManager.php(126): Mpociot\\Pipeline\\Pipeline->then(Object(Closure))
#7 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/BotMan.php(639): BotMan\\BotMan\\Middleware\\MiddlewareManager->applyMiddleware('sending', Array, Array, Object(Closure))
#8 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/BotMan.php(626): BotMan\\BotMan\\BotMan->sendPayload(Array)
#9 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/Messages/Conversations/Conversation.php(170): BotMan\\BotMan\\BotMan->reply(Object(BotMan\\BotMan\\Messages\\Outgoing\\OutgoingMessage), Array)
#10 /opt/lampp/htdocs/book-laraconeu-chatbot/app/Http/Conversations/FaqLocationConversation.php(22): BotMan\\BotMan\\Messages\\Conversations\\Conversation->say(Object(BotMan\\BotMan\\Messages\\Outgoing\\OutgoingMessage), Array)
#11 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/Traits/HandlesConversations.php(28): App\\Http\\Conversations\\FaqLocationConversation->run()
#12 /opt/lampp/htdocs/book-laraconeu-chatbot/routes/botman.php(55): BotMan\\BotMan\\BotMan->startConversation(Object(App\\Http\\Conversations\\FaqLocationConversation))
#13 [internal function]: App\\Providers\\RouteServiceProvider->{closure}(Object(BotMan\\BotMan\\BotMan))
#14 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/BotMan.php(478): call_user_func_array(Object(Closure), Array)
#15 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/botman/botman/src/BotMan.php(408): BotMan\\BotMan\\BotMan->callMatchingMessages()
#16 /opt/lampp/htdocs/book-laraconeu-chatbot/app/Http/Controllers/BotManController.php(18): BotMan\\BotMan\\BotMan->listen()
#17 [internal function]: App\\Http\\Controllers\\BotManController->handle()
#18 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): call_user_func_array(Array, Array)
#19 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction('handle', Array)
#20 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Route.php(212): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(App\\Http\\Controllers\\BotManController), 'handle')
#21 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Route.php(169): Illuminate\\Routing\\Route->runController()
#22 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(665): Illuminate\\Routing\\Route->run()
#23 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#24 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#25 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(68): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#28 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#29 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#30 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#31 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#32 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#33 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(63): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#34 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#37 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#38 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#39 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(66): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#40 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#41 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#42 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#43 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#44 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(642): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#45 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(608): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#46 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Router.php(597): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#47 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#48 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(30): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#49 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#50 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Fideloper\\Proxy\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#51 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#52 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#53 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#54 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#55 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(31): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#56 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#57 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#58 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#59 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#60 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#61 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#62 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(151): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#63 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#64 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#65 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#66 /opt/lampp/htdocs/book-laraconeu-chatbot/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#67 /opt/lampp/htdocs/book-laraconeu-chatbot/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#68 {main}
"} 

I partially solved by doing the changes below. However, no map is shown on Facebook. image

image

Another question, which are the icons after "Amsterdam"?

christophrumpel commented 6 years ago

Hey, the icon was the flag of Netherlands 🇳🇱

And regarding the map. This is working differently for Facebook. This is why there is a different method than to create the question object. See here: https://github.com/christophrumpel/bcwp-laraconeu-chatbot/blob/production/app/Http/Conversations/FaqLocationConversation.php

andreshg112 commented 6 years ago

Yeah, sorry! I haven't realized that's the next part of the lesson in your book. I'll be checking it.

christophrumpel commented 6 years ago

Yeah np 👍

andreshg112 commented 6 years ago

How can I use the Netherlands flag? If I try to copy it, It just copy the text "netherlands".

christophrumpel commented 6 years ago

Which editor do you use? Normally you should be able to just copy it. For me it works.

andreshg112 commented 6 years ago

I'm using VS Code for Ubuntu. However, If I try to copy the flag here on Github, I get the same text "netherlands".

christophrumpel commented 6 years ago

Hmm I can't tell what it is not working, but maybe you can try to copy one from here https://emojikopieren.de/