-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Description
Hello There,
I'm having some issues with interactive buttons in a conversation.
I have copied everything relevant from botman studio and everything is working with the exception of buttons and menu list interactions.
When i click a button, i get by fallback message '' Sorry i don't understand that command " As apposed to responding with a joke or quote.
I'm sure i'm missing a configuration or something, but I can't for the life of me figure out what the issue is.
route/botman.php
<?php
use App\Http\Controllers\BotManController;
$botman->hears('Hi', function ($bot) {
$bot->reply('Hello!');
});
$botman->hears('Start conversation', BotManController::class.'@startConversation');
$botman->fallback(function($bot) use ($actions) {
$bot->reply("Sorry i don't understand that command");
});
Botman controller
/**
* Place your BotMan logic here.
*/
public function handle(Request $request)
{
$botman = app('botman');
$botman->listen();
}
public function startConversation(BotMan $bot)
{
$bot->startConversation(new ExampleConversation());
}
Example conversation
<?php
namespace App\Conversations;
use Illuminate\Foundation\Inspiring;
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;
use Illuminate\Support\Facades\Log;
class ExampleConversation extends Conversation
{
/**
* First question
*/
public function askReason()
{
$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) {
Log::info("Is interactive reply ? " . $answer->isInteractiveMessageReply());
$this->say("Is interactive reply ? " . $answer->isInteractiveMessageReply());
$this->say($answer->getValue());
if ($answer->isInteractiveMessageReply()) {
Log::info("Inside interactive message reply");
Log::Info("Answer value : " . $answer->value());
if ($answer->getValue() === 'joke') {
$responseContent = file_get_contents('http://api.icndb.com/jokes/random');
Log::info($responseContent);
$joke = json_decode($responseContent);
$this->say($joke->value->joke);
} else {
$this->say(Inspiring::quote());
}
}
});
}
/**
* Start the conversation
*/
public function run()
{
$this->askReason();
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels