Reputation: 345
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.
Upvotes: 2
Views: 1915
Reputation: 15
Try this: "InputFieldState": "minimized".
Here is an example
keyboard": { "Type": "keyboard", "InputFieldState": "minimized", "Buttons": [ { "Columns": "2", "Rows": "2", "BgColor": "#000000", ..... ..... }
Upvotes: 1
Reputation: 19
Viber documentation is not good enough. As I tried, You should include "min_api_version": 4
in the JSON message.
Upvotes: 1
Reputation: 11
If you send a TextMessage without a keyboard and then send KeyBoardMessage it's working.
Something like this :
bot.sendMessage(
response.userProfile,
new TextMessage('Test message')
);
setTimeout(() => {
bot.sendMessage(
response.userProfile,
new KeyboardMessage(
your_keyboard,
null,
null,
null,
3
)
);
}, 500);
But I still can't find a way to send TextMessage with hidden input field. Because doing it like this when the TextMessage is sent, the input field will occur and after some time when the KeyBoardMessage arrives it will hide it, and that isn't something that we are looking for :)
Upvotes: 0
Reputation: 151
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
Upvotes: 3