Ботман Телеграмма

Они могли бы помочь мне, я не знаю, как поместить кнопки в telegram, только в мессенджере facebook, где может быть ошибка?

$ botman-> hears ('1', function ($ bot) {$ bot-> reply ("• Версия Android 4.4.2 (KitKat) o превосходная • Espacio en memoria de almacenamiento • Оперативная память Memoria превосходная 1 ГБ • Duración de batería Superior - 12 часов непрерывной работы • Conexión - красный сотовый 3G o Superior • Conexión Интернет ");

$ bot-> reply ('Алгоритм ответа на вопрос?') ->addButton(Button::create('Расскажи анекдот')) ->addButton(Button::create('Дай мне необычную цитату' ')))

});

0 ответов

Это решается с помощью классов app / Conversations.php

<?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;

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) {
            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());
                }
            }
        });
    }
                     //clases dinamicas, cambiar estructura de base de datos  :v
    /**
     * Start the conversation
     */
    public function run()
    {
        $this->askReason();
    }
}

и в вашем botman.php:

$botman->hears('/start', function (BotMan $bot) {
    $bot->startConversation(new ExampleConversation());
});

Другие вопросы по тегам