答案 0 :(得分:2)
尝试一下。 定义键盘
const KEYBOARD_JSON = {
"Type": "keyboard",
"InputFieldState": "hidden",
"Buttons": [{ // This is just an example
"Columns": 6,
"Rows": 1,
"ActionType": "reply",
"ActionBody": "Get started",
"Text": "Get started",
"BgColor": "#F0923F",
"TextSize": "regular",
"TextHAlign": "center",
"TextVAlign": "middle",
"Silent": "true"
}]
}
使用带有以下可选参数的KeyboardMessage构造函数定义消息。
const your_message = new KeyboardMessage(KEYBOARD_JSON, null, null, null, 3); // If it didn't work with min_api_version 3, try 4
答案 1 :(得分:1)
Viber 文档不够好。正如我所尝试的,您应该在 JSON 消息中包含 "min_api_version": 4
。
答案 2 :(得分:1)
试试这个: "InputFieldState": "最小化"。
这是一个例子
keyboard": { "Type": "keyboard", "InputFieldState": "minimized", "Buttons": [ { "Columns": "2", "Rows": "2", "BgColor": "#000000", ..... ..... }
答案 3 :(得分:0)
如果您发送不带键盘的TextMessage,然后发送KeyBoardMessage,它将正常工作。
类似这样的东西:
bot.sendMessage(
response.userProfile,
new TextMessage('Test message')
);
setTimeout(() => {
bot.sendMessage(
response.userProfile,
new KeyboardMessage(
your_keyboard,
null,
null,
null,
3
)
);
}, 500);
但是我仍然找不到通过隐藏的输入字段发送TextMessage的方法。因为在发送TextMessage时这样做是这样的,所以输入字段会出现,并且在KeyBoardMessage到达一段时间后会隐藏它,而这并不是我们想要的东西:)