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 |
---|---|
| Directive type. In this case, it is ‘autocomplete’. |
| You can set the number of suggestions displayed in the suggestion box. |
| The suggestions array. |
| The words listed in this array are typed by the user, these words will not appear in the suggestion box |
| The API that returns the suggestions list. |