DEV Community

rajput2219
rajput2219

Posted on

How to add URL in Botman button in web-driver

Hello,

I want to add a URL in Botman button during conversation.

Where I want to when we click on the answer button it's should be redirect to a URL in a new tab.

I use ButtonTemplate but it's work on facebook messenger but I want to use it with simple web-driver where it's shown on browser.

Please help.

Code is given below.

<?php
namespace App\Http\Conversations;
use BotMan\BotMan\Messages\Incoming\Answer;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\BotMan\Messages\Conversations\Conversation;

class SelectServiceConversation extends Conversation
{
public function askService()
{
$question = Question::create('What kind of Service you are looking for?')
->callbackId('select_service')
->addButtons([
Button::create('Mobile')->value('Mobile'), // Here we want to add URL which should be redirect on new page after click

            Button::create('Charger')->value('Mobile'),
            Button::create('Battery')->value('Mobile'),
        ]);

    $this->ask($question, function(Answer $answer) {
        if ($answer->isInteractiveMessageReply()) {
            $this->bot->userStorage()->save([
                'service' => $answer->getValue(),
            ]);
        }
    $this->bot->startConversation(new NextConversation()); // Trigger the next conversation
    });  

}

public function run()
{
    $this->askService();
}

}

Top comments (0)