无法使电报内联按钮起作用

时间:2016-07-08 09:45:04

标签: node.js telegram botframework

我正在使用MS Bot框架,想要在完成文档后显示一些内联按钮,并且我在下面写了一些相关问题但是在session.send(temp)之后我没有在频道上获得任何按钮

var temp = {
"type": "Message",
"from": { "channelID":"telegram", "address": session.message.from.id},
"to": { "channelID":"telegram", "address": session.message.to.id},
"conversationId": session.message.conversationId,
"channelData": {
    "method": "editMessageReplyMarkup",
    "parameters": {
        "message_id": session.message.id,
            "reply_markup": {
                "inline_keyboard": [
                    [{"text": "Show me more options", "callback_data": "next"}],
                    [{"text": "Start a new search", "callback_data": "quit"}]
                ]
            }
        }
    }
};
session.send(temp);

2 个答案:

答案 0 :(得分:0)

BotFramework本身支持按钮,因此您不需要使用ChannelData。 (See Docs

main = mainWidget $ myDiv

myDiv = do
  let attrs = constDyn $ fromList
               [ ("width" , "500")
               , ("height" , "250")
               ]
  let cAttrs = constDyn $ fromList
               [ ("cx", "50")
               , ("cy", "50")
               , ("r", "40")
               , ("stroke", "green")
               , ("stroke-width", "3")
               , ("fill",  "yellow" )
               ]

  s <- elSvg "svg" attrs (elSvg "circle" cAttrs (return ()))
  return ()

elSvg tag a1 a2 = do
  elDynAttrNS' ns tag a1 a2
  return ()

ns :: Maybe String
ns = Just "http://www.w3.org/2000/svg"

答案 1 :(得分:0)

如果您确实希望通过channelData实现此目的,则必须对reply_markup字段的值进行字符串化,例如:

"reply_markup": JSON.stringify({
            "inline_keyboard": [
                [{"text": "Show me more options", "callback_data": "next"}],
                [{"text": "Start a new search", "callback_data": "quit"}]
            ]
        })