setkyar / laravel-messenger-bot-management

:smile: Messenger bot Q&A management with Laravel
52 stars 17 forks source link

Bot Loop command #4

Closed OrbitPodium closed 5 years ago

OrbitPodium commented 8 years ago

Hello,

I had install this app but after my "hi" message, bot answers me "hello" and takes in a loop "Sorry. I don’t understand you." in "app/Messenger/Helpers/Messenger.php" file, the foreach cycle assumes $command = ""; and it allways fall in default message. I comment the line "$this->bot->send(new Message($message['sender']['id'], 'Sorry. I don’t understand you.'));" and after that seems work fine. you think review this issue?

setkyar commented 8 years ago

@OrbitPodium - Sorry. I don’t understand you. is default message. If Bot does not know Questions. It will answer default message. If you don't want to show user to default message just comment it out this line or add/modify it yourself.

OrbitPodium commented 8 years ago

@setkyar Yes this is the default message but if you start the chat and give a wrong command (see my attachment on red color) the bot answers the default message. After that, if you give right command (see my attachment on green color) the bot answers the respective message but after that, if there's no message from chat user, the bot goes to a loop in default message. I have to comment out the default message to avoid the default message cycle. Have you understand the issue? if the chat user gives no message the bot turns in default loop.

chat_bot

setkyar commented 8 years ago

@OrbitPodium It worked fine on my one. But, I will check it out again. And will solve it out. 👍

setkyar commented 8 years ago

@OrbitPodium Does not loop in my side. message does not loop

OrbitPodium commented 8 years ago

@setkyar I simply deploy the github repository and after that, made a composer install, make migrations and seed and voilá: the bot is working! Could you have in mind a reason for this loop? Of course i could code a workaround but i'm keeping understand why this happen on my installation.

andreshg112 commented 7 years ago

I got the same error. captura de pantalla de 2017-03-29 22-55-22

andreshg112 commented 7 years ago

I've solved it using this:

` if (!empty($command)) { // Handle command $bot_answer = Answer::where('command', '=', strtolower($command))->first();

                    if ($bot_answer) {
                        $this->bot->send(new Message($message['sender']['id'], $bot_answer->answer));
                    } else {
                        //Default
                        $this->bot->send(new Message($message['sender']['id'], 'Sorry. I don’t understand you.'));
                    }
                }`
setkyar commented 5 years ago

@OrbitPodium Thanks, I will check out and will fix on next release.