DEV Community

rajput2219
rajput2219

Posted on

1

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();
}

}

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay