2

我有一个示例 Telegram Bot,已集成到我的 api.ai 帐户中。我想像下面一样显示键盘按钮,但似乎 api.ai 只是向电报发送正文回复。知道如何实现我刚才描述的内容吗?请告知方向和/或解决方案。谢谢!

当我从 api.ai 发送回复时,我想显示 Telegram 的键盘自定义按钮

我有一个 Fulfillment webhook url,当我的示例 Intent 被调用时返回这个 json

{
  "id": "af681b42-9ced-4f8f-ab0c-0559b210dc1a",
  "timestamp": "2016-07-15T01:47:30.896Z",
  "result": {
    "source": "agent",
    "resolvedQuery": "Hello",
    "action": "show-main",
    "actionIncomplete": false,
    "parameters": {},
    "contexts": [],
    "metadata": {
      "intentId": "e477976e-2412-4066-b320-48d7dedd5dfe",
      "webhookUsed": "true",
      "intentName": "Adobo"
    },
    "fulfillment": {
      "speech": "Hello world!",
      "source": "index.php",
      "data": {
        "chat_id": 1,
        "text": "hi there",
        "parse_mode": "HTML",
        "reply_markup": {
          "keyboard": [
            "A1",
            "A2"
          ],
          "one_time_keyboard": true,
          "resize_keyboard": true
        }
      }
    },
    "score": 1
  },
  "status": {
    "code": 200,
    "errorType": "success"
  },
  "sessionId": "4cb02864-9925-4d4c-a0f1-14dbab44add7"
}

我在“数据”下添加了 json 格式的回复标记键盘。

4

1 回答 1

3

您之前是否能够单独(不使用键盘)发送文本?

我认为这是一个语法错误。该"keyboard"字段应该是一个数组数组。请尝试用以下代码段替换该字段。

"reply_markup": {
    "keyboard": [
        ["Day", "Week", "Month"],
        ["Users", "Retention"],
        ["sessions", "Events"],
        ["Back"]
    ],
    "one_time_keyboard": true,
    "resize_keyboard": true
}
于 2016-07-15T07:05:32.613 回答