polyskalov / botman-viber-driver

Viber driver for botman —  a PHP library to build chat bots
https://botman.io
MIT License
7 stars 5 forks source link

ErrorException: Undefined index: url in file ViberDriver.php on line 202 #5

Open EduardMalik opened 4 years ago

EduardMalik commented 4 years ago

Hello @polyskalov

When i start conversation for example, i use ExampleConversation from botman studio default create:

    $question = Question::create("Huh - you woke me up. What do you need?")
        ->fallback('Unable to ask question')
        ->callbackId('ask_reason')
        ->addButtons([
            Button::create('Tell a joke')->value('joke'),
            Button::create('Give me a fancy quote')->value('quote'),
        ]);

    return $this->ask($question, function (Answer $answer) {
        if ($answer->isInteractiveMessageReply()) {
            if ($answer->getValue() === 'joke') {
                $joke = json_decode(file_get_contents('http://api.icndb.com/jokes/random'));
                $this->say($joke->value->joke);
            } else {
                $this->say(Inspiring::quote());
            }
        }
    });

ViberDriver not start conversation, and i see Excception:

    ErrorException: Undefined index: url in file /home/hotadd/www/chatbot/vendor/polyskalov/botman-viber-driver/src/ViberDriver.php on line 202

Stack trace:

  1. ErrorException->() /home/hotadd/www/chatbot/vendor/polyskalov/botman-viber-driver/src/ViberDriver.php:202
  2. Illuminate\Foundation\Bootstrap\HandleExceptions->handleError() /home/hotadd/www/chatbot/vendor/polyskalov/botman-viber-driver/src/ViberDriver.php:202
  3. TheArdent\Drivers\Viber\ViberDriver->convertQuestion() /home/hotadd/www/chatbot/vendor/polyskalov/botman-viber-driver/src/ViberDriver.php:241
  4. TheArdent\Drivers\Viber\ViberDriver->buildServicePayload() /home/hotadd/www/chatbot/vendor/botman/botman/src/BotMan.php:642
  5. BotMan\BotMan\BotMan->reply() /home/hotadd/www/chatbot/vendor/botman/botman/src/Messages/Conversations/Conversation.php:66
  6. BotMan\BotMan\Messages\Conversations\Conversation->ask() /home/hotadd/www/chatbot/app/Conversations/ExampleConversation.php:35
  7. App\Conversations\ExampleConversation->askReason() /home/hotadd/www/chatbot/app/Conversations/ExampleConversation.php:43
  8. App\Conversations\ExampleConversation->run() /home/hotadd/www/chatbot/vendor/botman/botman/src/Traits/HandlesConversations.php:28
  9. BotMan\BotMan\BotMan->startConversation() /home/hotadd/www/chatbot/app/Http/Controllers/BotManController.php:40
    1. App\Http\Controllers\BotManController->startConversation() /home/hotadd/www/chatbot/vendor/botman/botman/src/BotMan.php:495
    2. call_user_func_array() /home/hotadd/www/chatbot/vendor/botman/botman/src/BotMan.php:495
    3. BotMan\BotMan\BotMan->callMatchingMessages() /home/hotadd/www/chatbot/vendor/botman/botman/src/BotMan.php:425
    4. BotMan\BotMan\BotMan->listen() /home/hotadd/www/chatbot/routes/botman.php:18

Can you look this? Many thanks!

polyskalov commented 4 years ago

Thank! Yeah sure i look at it next week

rajendrap123 commented 4 years ago

@polyskalov let us know when you have fix for it, thanks for your efforts.

polyskalov commented 4 years ago

Guys, sorry for the delay. I'll try to fix it today or tomorrow

I fixed an error from this issue (not committed yet), but sending messages from the example doesn't work.

rajendrap123 commented 4 years ago

have you fixed it now?On 08-Jul-2020 3:33 PM, Andrey Polyskalov notifications@github.com wrote: Guys, sorry for the delay. I'll try to fix it today or tomorrow I fixed an error from this issue (not committed yet), but sending messages from the example doesn't work.

—You are receiving this because you commented.Reply to this email directly, view it on GitHub, or unsubscribe.

EduardMalik commented 4 years ago

Hello @polyskalov. Is there any news on this issue?

polyskalov commented 4 years ago

@EduardMalik No, it's something weird. The function inside the driver does not send an incoming message in the parameter, so I cannot get the sender ID to send the message back.

I don't know why, it's taken a long time. If someone can help me determine the reason, or test it, I'd really appreciate it.

YaroslavKozhemiaka commented 3 years ago

Hello @polyskalov, @EduardMalik. This error triggered when you try to send question instance without actions. Example:

$question = Question::create("What animal pearson are you?")
            ->addButtons(
                [
                    Button::create("I like cats.")->value("cat"),
                    Button::create("I like dogs.")->value("dog")
                ]
            );

print_r - question argument method convertQuestion

Array
(
    [0] => Array
        (
            [name] => I like cats.
            [text] => I like cats.
            [image_url] => 
            [type] => button
            [value] => cat
            [additional] => Array
                (
                )

        )

    [1] => Array
        (
            [name] => I like dogs.
            [text] => I like dogs.
            [image_url] => 
            [type] => button
            [value] => dog
            [additional] => Array
                (
                )

        )

)

As you can see we haven't key url, which we try to call in line 202