2016-07-14 47 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進行通信。 –

相關問題