Replies: 1 comment 3 replies
-
For any driver that supports buttons, I use them for navigation. For voice bots, I use DTMF and STT, the first one on the ID of the button, the second one on the label of the button. I wrote my own trait to easily create questions: <?php
namespace FilippoToso\Botman\Helpers\Traits;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use Illuminate\Support\Arr;
trait Questionable
{
protected function question($message, $buttons)
{
$payload = [];
foreach ($buttons as $value => $button) {
if (is_a($button, Button::class)) {
$payload[] = $button;
} elseif (is_array($button)) {
$payload[] = Button::create($button['label'])
->value($value)
->additionalParameters(Arr::except($button, ['label']));
} else {
$payload[] = Button::create($button)
->value($value);
}
}
return Question::create($message)->addButtons($payload);
}
} I pass to it the question (i.e What do you need) and an associative array for the buttons. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Has anyone come up with a structured way to implement a menu/navigation system?
e.g. press 1 for aaa, press 2 for bbb, press 0 to return...
Beta Was this translation helpful? Give feedback.
All reactions