VOGO Voice – Knowledge Base

filter Function

Estimated reading time: 4 min

In this in-depth tutorial, you will learn how to write the filter function as well as how to use this function to filter data from a collection. In short, the filter function iterates over each element of the collection and checks for the match based on the parameters and returns a filtered array of matching elements. The two parameters are the collection and the key-value pair i.e. the value that needs to be matched. 

The comprehensive instructions combined with highlighted screenshots will offer the required directions needed to implement the aforementioned function which will be demonstrated by means of a use case showcasing the list of available books at a library. Herein, the filter function is implemented for the purpose of filtering data based on the availability of books.


  • VOGO Voice account: https://www.vogovoice.com/
  • Access rights to the Interactions section.
  • Access rights to the Interaction builder platform.

Create a Custom Intent 

Make a suitable intent to be invoked for executing an interaction flow mapped to it.

Create an intent titled ‘Available Books’ with suitable sample utterances linked to it. The sample utterance for this intent would be: “List me the books that are available”, “Give me the list of available books”, and “List available books”. These sample utterances will serve the purpose of updating the user with the list of available books at the library.

To learn how to create custom intents refer to the guide: https://university.vogovoice.com/kb/creating-intents/

Steps to create an interaction flow

  1. Log into your VOGO Voice account to be directed to VOGO Voice Management Console (https://account.vogovoice.com)
  1. Navigate to Interactions on the vertical bar displayed on the left-hand side of the Dashboard.

           Dashboard > Interactions

3. Now, click on the Interactions button at the bottom right-hand corner of the screen. Select the ‘Available books’ intent to be directed onto the Interaction builder platform.

4.  In the flow diagram area, you will be able to see the Start and Response components. 

5. Unlink the Start component from the Response card by clicking the delete icon placed in the middle of the chain.

6. Now, drag and drop an Add Variables component onto the flow diagram area.

7. Now mouse over the top right corner of the Add Variables component. Click on the pencil icon that appears. This will open up its configuration window. 

8. Configure the Add Variables component by adding the key-value pairs as shown in the screenshot below. Fill in the first variable name as books and add the array as the value in it, the format and content of which is provided below in detail. This array contains the list of books in the library along with their status. If the book is available the status will show up as available and vice versa. Then, set the datatype as Array.  To know more about data types, click here.

"id": 1,
"name": "King Lear",
"status": "Available"
"id": 2,
"name": "Lolita",
"status": "Unavailable"
"id": 3,
"name": "Man and Superman",
"status": "Unavailable"
"id": 4,
"name": "My experiments with Truth",
"status": "Available"
"id": 5,
"name": "Oliver Twist",
"status": "Unavailable"
"id": 6,
"name": "Othello",
"status": "Available"
"id": 7,
"name": "Pride and Prejudice",
"status": "Unavailable"

8. Now add another variable in the same Add Variables component and configure it as illustrated below. Name the newly added variable as available. To fulfill this step, a filter function is to be added.

9. To add the filter function in the value field, navigate to the Data tab adjacent to the Components on the top left-hand side of the interaction builder platform. 

10. Click on the Data part and in the search bar type ‘filter’. From the drop-down that appears, click on the plus button beside the Collection, and this will bring up the filter function as shown below.

11. Drag and drop the filter function in the value field corresponding to the available variable name. This will automatically generate the filter function in the respective field. Now continue to configure as illustrated below. Click the plus button that appears under the heading Arguments and add the first argument as var.books which is the array that contains the list of books in the library. Retain the data type as Path for the first argument. Set the second argument as {“status”: “Available” } i.e.the key-value pair that will fetch the match from the array. Set the data type as Object for the second argument.

🖍 Note: The var.available will posit the new array with the matched objects from the second argument.

12. Now drag and drop a Response component onto the flow canvas and connect it to the already configured Add Variables component as shown below.

13. Configure the Response component as shown right below. To proceed click on the Voice icon on the top right-hand side of the Response component. Clicking on the voice icon opens a Speak pop-up window with a field titled Say wherein you need to type the following response.

Say: Here is the list of available books. They are,
{{#showList var.available}} {{name}} {{/showList}}

Here we render the list of available books using the showList function which will interpret the data in var.available as list. The template {{#showList var.available}} {{name}} {{/showList}} will provide the value of the name from each of the objects in var.available in a list format.

🖍Note: Ensure to click the Save button to save the interaction flow as and when edits are made.

To add a display message in a display voice-assisted device.

  1. Click on the Computer icon, and type in the field titled Display Message of the Show pop-up window. 
  2. Populate the required fields and click the Save button. 

Title: Available Books
Display Message: {{#each var.available}} {{name}} {{/each}}

To learn about the each and showList function visit https://university.vogovoice.com/kb/template-engine/

Testing and Validation 

  1. Click on the Test button next to the Flow Editor button on the interaction builder platform.

2. In the Tests pop-up window that appears, click the + button on its top right-hand corner. 

3. Fill in the Name field of the Test Response window that shows up. In the Conversation section of the Test Response, the Available Books intent through which this interaction flow has been initiated will be auto-generated in the User invokes field as shown below.  Click Save to perform the test.

4. To validate the Test Response, click on the lightning symbol on the left-hand side of the test case as shown below.

5. The resultant Test Response window displays the output.

Congratulations! You have successfully learned how to implement the filter function to filter data in the desired interaction model based on the requirements of the skill.

👍 Note: To test the functioning of the interactions on your device you have to deploy the custom skill to facilitate the skill with the new edits. To accomplish this, click on the Deploy button seen at the bottom of the Skill Settings pop-up window.

To know how to deploy a custom skill visit https://university.vogovoice.com/kb/deploying-a-skill/

Was this article helpful?
Dislike 0
Previous: Dynamic Slots
Next: find Function