Reputation: 51
I'm writing a Viber "keyboard" and I want to create a button which opens a link in the internal browser, which according to this doc doc should be done by sending JSON post to https://chatapi.viber.com/pa/send_message . I'm setting buttons' parameters "ActionType": "open-url" and the "ActionBody":"example.com". The parameter "OpenURLType": "internal" is optional and its default value is internal. No matter what I write as value of this parameter, or if I omit it the response is successful, but the url opens in an external browser.
{
"receiver":"some hash",
"keyboard":{
"Type":"keyboard",
"DefaultHeight":false,
"Buttons": [
{
"Columns": null,
"Rows": null,
"BgColor": "#7eceea",
"Silent": null,
"BgMediaType": null,
"BgMedia": null,
"BgMediaScaleType": null,
"ImageScaleType": null,
"BgLoop": null,
"ActionType": "open-url",
"ActionBody": "https://www.wikipedia.org/",
"Image": null,
"Text": "open this ",
"TextVAlign": null,
"TextHAlign": null,
"TextPaddings": null,
"TextOpacity": null,
"TextSize": "small",
"OpenURLType": "internal",
"OpenURLMediaType": "nulll",
"TextBgGradientColor": null,
"TextShouldFit": null
}
]
}
}
and the response 200 OK
{
"status": 0,
"status_message": "ok",
"message_token": 5469236575712199350,
"chat_hostname": "SN-CHAT-01_"
}
When I played around with the other optional parameters I noticed inconsistency. Some of them produce an error when you give some gibberish value (like setting the ActaionType to "operghj"). Other optional parameters don't. For example
{
"status": 3,
"status_message": "keyboard is not valid. [instance value (\"operghj\") not found in enum (possible values: [\"reply\",\"open-url\",\"\"])]",
"chat_hostname": "SN-CHAT-01_"
}
Does anybody has any idea how to fix this or what I'm doing wrong?
Upvotes: 0
Views: 508
Reputation: 51
The parameter "min_api_version": 7
, has to be added to the json, in order to open the url internally.
{
"receiver":"some hash",
"min_api_version": 7,
"keyboard":{
"Type":"keyboard",
"DefaultHeight":false,
"Buttons": [
{
"Columns": null,
"Rows": null,
"BgColor": "#7eceea",
"Silent": null,
"BgMediaType": null,
"BgMedia": null,
"BgMediaScaleType": null,
"ImageScaleType": null,
"BgLoop": null,
"ActionType": "open-url",
"ActionBody": "https://www.wikipedia.org/",
"Image": null,
"Text": "open this ",
"TextVAlign": null,
"TextHAlign": null,
"TextPaddings": null,
"TextOpacity": null,
"TextSize": "small",
"OpenURLType": "internal",
"OpenURLMediaType": "nulll",
"TextBgGradientColor": null,
"TextShouldFit": null
}
]
}
}
Upvotes: 0