polyskalov/botman-viber-driver

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

EduardMalik opened this issue · 7 comments

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
  10. App\Http\Controllers\BotManController->startConversation() /home/hotadd/www/chatbot/vendor/botman/botman/src/BotMan.php:495
  11. call_user_func_array() /home/hotadd/www/chatbot/vendor/botman/botman/src/BotMan.php:495
  12. BotMan\BotMan\BotMan->callMatchingMessages() /home/hotadd/www/chatbot/vendor/botman/botman/src/BotMan.php:425
  13. BotMan\BotMan\BotMan->listen() /home/hotadd/www/chatbot/routes/botman.php:18

Can you look this? Many thanks!

Thank! Yeah sure i look at it next week

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

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.

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

@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.

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