代码之家  ›  专栏  ›  技术社区  ›  comalex3

在带有sourceEvent的bot框架仿真器中显示按钮

  •  1
  • comalex3  · 技术社区  · 6 年前

    我不想用 builder.Prompts.choice 因为我想让用户键入答案不只是点击按钮。因此,我使用sourceEvent,与facebook messenger配合得很好,但我知道我没有能力在模拟器中测试我的机器人,因为按钮不会出现。

    replyMessage.sourceEvent({
        facebook: {
            quick_replies: [
                {
                    "content_type": "text",
                    "title": "Money Management",
                    "payload": "Money Management"
                },
                {
                    "content_type": "text",
                    "title": "Retirement Plans",
                    "payload": "Retirement Plans"
                }
            ]
        },
    });
    

    1 回复  |  直到 6 年前
        1
  •  0
  •   comalex3    6 年前

    enter image description here 好的截图我们看到按钮作为附件到达机器人模拟器。

    let replyMessage = new builder.Message(session).text("hi");
    replyMessage.addAttachment(
                {
                    "contentType": "application/vnd.microsoft.card.hero",
                    "content": {
                        "buttons": [ {"type": "postBack", "title": "Your title", "value": "your value"} ]
                    }
                }
            );