...
Code Block |
---|
msg.payload.orbita.directive= [{ "type": "button", "buttons": [ { "type" : "js", "text": "Button with script", "value": ` if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { console.log("Geolocation is not supported by this browser."); callback({utterance: "help"}); } function showPosition(position) { console.log("Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude); callback({utterance: "help", data: [position.coords.latitude, position.coords.longitude]}); } `, } ] }]; return msg; |
Do not use single quotes (') in the value property.
Usage
If you want a button to display when the help intent is triggered. Place a function node as shown in the below screenshot and place any of the sample codes given in this document.
...