Viber - 发送键盘消息时隐藏用户字段输入

Viber - Hide the user field input when sending Keyboard Message

我正在尝试使用键盘发送短信。我在 docs 中发现我可以通过将 InputFieldState 的值设置为 hidden 来隐藏用户的输入字段,但是当我发送消息时用户输入字段仍然存在.

预期行为

实际行为

试试这个。 定义键盘

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

如果您在没有键盘的情况下发送 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 到达一段时间后它将隐藏它,这不是我们正在寻找的东西:)

Viber 文档不够好。正如我所尝试的,您应该在 JSON 消息中包含 "min_api_version": 4

试试这个: "InputFieldState": "最小化".

这是一个例子

keyboard": {
    "Type": "keyboard",
    "InputFieldState": "minimized",
    "Buttons": [
      {
        "Columns": "2",
        "Rows": "2",
        "BgColor": "#000000",
        .....
        .....
      }