Reputation: 1
I'm currently working on location based service in viber chatbot on Node, but either viber docs are missing information or i don't understand something important.
The methods i need are location-picker
to make a button for sharing a location with my bot and open-map
to open a default map application for users device and display info there on pressing a button. I neither managed to find any working example of this functionality nor find any actual data on how the keyboard requests for these should look like.
I tried making an object like that:
"Buttons": {
"Columns":6,
"Rows":3,
"ActionType": "open-map",
"Map": {
"Latitude": data.latitude,
"Longitude": data.longitude
},
"Image": data.image
},
But this returns UnhandledPromiseRejectionWarning on sending it to viber.
(Of course that's not the entire keyboard object, but its 'not-working' part; if i change ActionType to "reply" and add reply text, it will work just fine)
For location-picker i tried
"Buttons": {
"Columns": 6,
"Rows": 1,
"BgColor": "#26CF94",
"BgLoop": true,
"ActionType": "location-picker",
"Text": "Share location",
},
But this returns UnhandledPromiseRejectionWarning.
From that point, the problem is obvious, something wrong with keyboard object sent, but i can't figure out what's exactly wrong. So what is the right way to do that?
p.s. I'm using viber-bot library to manage requests
Upvotes: 0
Views: 689
Reputation: 1
Correct:
"Buttons": {
"Columns": 6,
"Rows": 1,
"BgColor": "#26CF94",
"BgLoop": true,
"ActionType": "location-picker",
"ActionBody" : "location",
"Text": "Share location",
},
ActionBody
- is mandatory argument!
Upvotes: 0
Reputation: 938
There is no issue with the button . The issue is with API Version. You need to specify API version while preparing message .
var registerMessage = new TextMessage("Please register your account to continue", registerKeyboard,undefined,undefined,undefined,3)
This is for text message. And i am using API Version 3 . Similarly you can do it for other types of message and other api version
Upvotes: 0