node.jsbotschatbotviber

Viber - Hide the user field input when sending Keyboard Message


I'm trying to send a Text Message with a keyboard. I found in the docs that I can hide the input field of the user by setting the value of InputFieldState to hidden but the user input field is still there when I send the message.

Expected Behavior enter image description here

Actual Behavior enter image description here


Solution

  • Try this. Define the keyboard

    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"
     }]
    }
    

    define the message using the KeyboardMessage constructor with the below optional arguments.

    const your_message = new KeyboardMessage(KEYBOARD_JSON, null, null, null, 3); // If it didn't work with min_api_version 3, try 4