Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

...

Attachments
previewfalse
uploadfalse
oldfalse
patterns.*json
Note

If you are importing this Button Sample.json, please make sure that you have only one HelpIntent in your project.

Related Articles

Filter by label (Content by label)
showLabelsfalse
max5
showSpacefalse
cqllabel = "experience-manager"