Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Orbita supports the autocomplete feature in their chatbots. You can achieve this by using the Autocomplete directive.

In the below example, we use the autocomplete feature that will give country suggestions based on the letters typed.

You will get suggestion only after you type three letters.

You can enable the auto-complete feature by placing the below code in the function node in the Experience Designer.

if(!msg.payload.orbita) {
    msg.payload.orbita = {};
    }
    if(!msg.payload.orbita.directive) {
    msg.payload.orbita.directive = [];
    }
    
    var country = ['Belarus', 'Belgium', 'Belize', 'Grenada', 'Canada', 'Madagascar'];
    var suggestion=[]; 
    for(var i=0;i<country.length;i++){
        var obj={
            "item": country[i],
            "value": country[i]
        }
        suggestion.push(obj)
    }
    
    msg.payload.orbita['directive'].push({
        'type': 'autocomplete',
        'maxSuggestions': 5,
        'items':suggestion,
        'excludeList': ['what','for'],
        "url":""}
        );
    return msg

The ‘item’ is the indexed parameter and the 'value' is shown in the suggestions.

Property

Description

type

Directive type. In this case, it is ‘autocomplete’.

maxSuggestions

You can set the number of suggestions displayed in the suggestion box.

items

The suggestions array.
Note: When the url field is present, the items field should be empty.

excludeList

The words listed in this array are typed by the user, these words will not appear in the suggestion box

url

The API that returns the suggestions list.
Note: When the items field is present, the url field should be empty

  • No labels