2016-07-14 82 views
1

我有一个示例Telegram Bot,我已经集成在我的api.ai帐户中。我想显示如下所示的键盘按钮,但似乎api.ai只发送正文回复给电报。任何想法我怎么能达到我刚才所描述的?请告知方向和/或解决方案。谢谢!如何在与api.ai集成的电报机器人中显示键盘按钮?

I wanted to display the Keyboard custom buttons for Telegram when I send a reply from api.ai

我有一个配送网络挂接URL时,我的样本的意图是调用

{ 
    "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格式添加在“数据”返回该JSON。

+0

你能提供你试过的例子吗? – mhatch

+0

嗨,我已经更新了我的帖子上面。 –

回答

1

以前你能单独发送文本吗(没有键盘)?

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

"reply_markup": { 
    "keyboard": [ 
     ["Day", "Week", "Month"], 
     ["Users", "Retention"], 
     ["sessions", "Events"], 
     ["Back"] 
    ], 
    "one_time_keyboard": true, 
    "resize_keyboard": true 
} 
+0

谢谢,但这不是问题,我尝试使用Webhook的电报,它的工作。现在我的电报webhook使用他们的/ query API与api.ai进行通信。 –

相关问题