Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
excludeRelated

You can use the We have introduced button directive to add the buttons that do a variety of actionsin the chatbot.

The directive “type” should be “button.

The List of Buttons in the Button Directive are :

  1. Default Button

  2. Button with Link

  3. Button with AJAX

  4. Button with script

You can use the sample code given in the below sections in a function node to get the buttons in the chatbot.

Default Button

Using the default button, you can trigger a custom utterance upon button click.

...

type: The “type” should be set to “js” for JavaScript.

...

...

Currently we support only JavaScript.

Sample Button code that executes a JavaScript

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"