简体   繁体   English

如何使用 Botman.io 创建松弛对话框

[英]How to create slack dialog using Botman.io

How do I create a Dialog box in Slack using Botman?如何使用 Botman 在 Slack 中创建对话框? I achieved creating a dropdown menu and button using Botman in the Slack app.我在 Slack 应用程序中使用 Botman 创建了一个下拉菜单和按钮。 But after selecting a value from the dropdown, I need to trigger a Slack dialog box.但是从下拉列表中选择一个值后,我需要触发一个 Slack 对话框。 How I can achieve it?我怎样才能实现它?

You can see the full implementation in this commit .您可以在此提交中看到完整的实现。

First, you have to extend the BotMan\\Drivers\\Slack\\Extensions\\Dialog class.首先,您必须扩展BotMan\\Drivers\\Slack\\Extensions\\Dialog类。 For example:例如:

<?php

namespace App\BotMan\Dialogs;

use BotMan\Drivers\Slack\Extensions\Dialog;

class TestDialog extends Dialog
{
    /**
     * Build your form.
     *
     * @return void
     */
    public function buildForm()
    {
        $this->title = 'Test dialog';
        $this->callbackId = 'test-dialog-callback-id';

        $this->text('Text', 'text');
    }
}

Then, you can send the dialog in your conversation 's run method:然后,您可以在对话的 run 方法中发送对话框:

<?php

namespace App\BotMan\Conversations;

use App\BotMan\Dialogs\TestDialog;
use BotMan\BotMan\Messages\Incoming\Answer;

class TestConversation extends Conversation
{
    public function run()
    {
        $response = $this->sendDialog(new TestDialog, function (Answer $answer) {
            $value = $answer->getValue()['text'];

            // ...
        });
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM