Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Viber-发送键盘消息时隐藏用户字段输入_Node.js_Bots_Chatbot_Viber - Fatal编程技术网

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

Node.js Viber-发送键盘消息时隐藏用户字段输入,node.js,bots,chatbot,viber,Node.js,Bots,Chatbot,Viber,我正试图用键盘发送一条短信。我在中发现,我可以通过将InputFieldState的值设置为hidden来隐藏用户的输入字段,但是当我发送消息时,用户输入字段仍然存在 预期行为 实际行为 试试这个。 定义键盘 const KEYBOARD_JSON = { "Type": "keyboard", "InputFieldState": "hidden", "Buttons": [{ // This is just an example "Columns": 6, "Rows

我正试图用键盘发送一条短信。我在中发现,我可以通过将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
试试这个。 定义键盘

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

如果您在没有键盘的情况下发送文本消息,然后发送键盘消息,则该消息正常工作

大概是这样的:

bot.sendMessage(
      response.userProfile,
      new TextMessage('Test message')
    );

    setTimeout(() => {
      bot.sendMessage(
        response.userProfile,
        new KeyboardMessage(
          your_keyboard,
          null,
          null,
          null,
          3
        )
      );
    }, 500);

但我仍然找不到一种方法来发送带有隐藏输入字段的文本消息。因为在发送文本消息时这样做,输入字段将出现,在键盘消息到达后一段时间后,它将隐藏它,而这不是我们要寻找的:

如果您在没有键盘的情况下发送文本消息,然后发送键盘消息,那么它正在工作

大概是这样的:

bot.sendMessage(
      response.userProfile,
      new TextMessage('Test message')
    );

    setTimeout(() => {
      bot.sendMessage(
        response.userProfile,
        new KeyboardMessage(
          your_keyboard,
          null,
          null,
          null,
          3
        )
      );
    }, 500);

但我仍然找不到一种方法来发送带有隐藏输入字段的文本消息。因为在发送文本消息时这样做,输入字段将出现,在键盘消息到达后一段时间,它将隐藏它,这不是我们要寻找的东西:

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

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

试试这个: InputFieldState:最小化

这里有一个例子

keyboard": { "Type": "keyboard", "InputFieldState": "minimized", "Buttons": [ { "Columns": "2", "Rows": "2", "BgColor": "#000000", ..... ..... } 试试这个: InputFieldState:最小化

这里有一个例子

keyboard": { "Type": "keyboard", "InputFieldState": "minimized", "Buttons": [ { "Columns": "2", "Rows": "2", "BgColor": "#000000", ..... ..... }
你把它整理好了吗?我也试过同样的方法,但没有效果。“管理”面板中也没有关闭它的选项。没有任何运气@Indikawijesoriya您是否成功将其排序?我也试过同样的方法,但没有效果。管理面板中也没有关闭它的选项。没有任何运气@indikawijesoriya您的方式无法解决作者描述的问题。在Viber bot API中,我们了解到onConversationStarted事件:…不允许帐户向用户发送消息;但是,它将允许向用户发送一条“欢迎消息”。。实际上,在您的示例中,您发送了两条消息—一条文本消息和一条键盘消息。不幸的是,在这种情况下,用户将只收到文本消息。注意:对于按特殊顺序发送两条或更多消息,您可以使用response arg:response.发送[new-TextMessage'text',new-KeyboardMessageoptions]……以数组形式发送。但通常,单独发送一条TextMessage和一条KeyboardMessage,并使用其他参数new-KeyboardMessageoptions,null,null,3是解决未加工选项问题的好主意。InputFieldState='hidden'和options.Silent=true。键盘配置。例外情况,由作者描述=你的方法不能解决作者描述的问题。在Viber bot API中,我们了解到onConversationStarted事件:…不允许帐户向用户发送消息;但是,它将允许向用户发送一条“欢迎消息”。。实际上,在您的示例中,您发送了两条消息—一条文本消息和一条键盘消息。不幸的是,在这种情况下,用户将只收到文本消息。注意:对于按特殊顺序发送两条或更多消息,您可以使用response arg:response.发送[new-TextMessage'text',new-KeyboardMessageoptions]……以数组形式发送。但通常,单独发送一条TextMessage和一条KeyboardMessage,并使用其他参数new-KeyboardMessageoptions,null,null,3是解决未加工选项问题的好主意。InputFieldState='hidden'和options.Silent=true。键盘配置。例外情况,由作者描述=