VOGO Voice – Knowledge Base

How to use Lookup Function

Estimated reading time: 5 min

Lookup is a function implemented within a custom interaction model for finding instances of objects. In other words, It is used to lookup properties of objects based on data from the input. The execution of this function is of use in situations wherein the data needs to be compared and matched with its instances to produce the output the end-user is seeking while interacting with the skill. “The simplest way to think of lookup is that it is a Map where the keys are Class objects and the value for each key is an instance of the key class”.

This instructional tutorial aims at illustrating a use-case on how to make use of a lookup function to retrieve the performance status of students using their ID. Adopting a comprehensive methodology, the tutorial is dedicated towards presenting a guided step-by-step walk-through to illustrate the execution of the lookup function to fetch the desired output representing the result status of students. The application of this function triggers the ID designated against the names of students within an array to be compared and matched with the object denoting the marks assigned against the respective student IDs.

Prerequisites: 

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

Create a custom intent

Create an appropriate intent to be invoked for executing an interaction flow mapped to it, the purpose here being to execute the lookup function within the custom interaction model to produce the desired result of fetching the examination results of students.

Create an intent titled ‘Lookup’ with suitable sample utterances mapped to it. The sample utterances for this intent would be: “Give me the results” & “Show me the results.”

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

Steps to create an interaction flow

Let’s walk you through the step-by-step process on how to build an interaction model that will illustrate the significance of the lookup function within a custom interaction model to fetch the desired output representing the result status of students.

1. Log into your VOGO Voice account to be directed to VOGO Voice Management Console (https://account.vogovoice.com)
2. Navigate to Interactions on the vertical bar displayed on the left-hand side of the Dashboard.
3. Click on the Interaction button at the bottom right-hand corner of the screen and select the ‘Lookup’ intent to be directed into the Interaction builder platform. 

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

5. Roll the mouse over the Response component to see the voice, computer and camera icon on the top right-hand side of the component.
6. Clicking on the Voice icon opens a Speak pop-up window with a field titled Say wherein you need to type the voice action welcoming the user.
Say: Welcome to the results page of Turner & Parker’s Technical High School.
7. Check the checkmark box in the Expect Response and type in the suitable Prompt message to proceed with the flow.
Prompt: Say next to see the results.
The same message will be replicated in the Reprompt field.
Reprompt: Say next to see the results.
8. Populate the field under Expectations by selecting the Global Intent Next from the drop-down list. 

🖍 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 video-enabled voice-assisted device

1. Click on the Computer icon, and type in a condensed version of the voice message in the field titled Display Message of the Show pop-up window.
2. Populate the required fields and click the Save button. 
Title: Results 
Display Message: Welcome to the results page of Turner & Parker’s Technical High School.

For further reference on how to populate the additional fields visit https://university.vogovoice.com/kb/guide-response-component/

9. Drag and drop the Add Variables component onto the flow canvas and connect the anchor symbol of Next on the Response card to the Add Variables component.

🖍 Note: To interconnect the different components click on their respective Anchor symbols so as to chain and hold them in the interaction flow.

10. Configure the Add Variables component by adding the key-value pair as shown below. Set the data types accordingly based on the inputs. The two variables representing the respective key-value pair are names and marks. The objective here is to produce the desired resultset of obtaining the list of student’s results  using the lookup function which will query the students’ ID in the array of data and compare it with the data grouped in the object to find a match and produce the list of results in accordance with the requirements of the skill. Populate the Add Variables component with the variables and input as illustrated below:

name: [{"Name":"Nick","id": "1"},{"Name":"James","id": "2"},{"Name":"Tony","id": "3"},{"Name":"Steve","id": "4"}] 
Set the data type as Array

mark:  { "1":{"Result":"Pass","status":"Average"}, "2":{"Result":"Fail","status":"Below Average"}, "3":{"Result":"Pass","status":"Good"}, "4":{"Result":"Pass","status":"Average"}}
Set the data type as Object

🖍 Note: The purpose of configuring the Add Variables card is to perform the task of calling to action the value assigned using the variable name in the subsequent response card within the interaction flow.

To learn about different template engines to be followed to run functions visit https://university.vogovoice.com/kb/template-engine/

11. Now drag and drop a Response component onto the flow canvas and connect the anchor symbol of Next on the Add Variables component to the Response card.

12. Click on the Voice icon of the Response card to open up the Speak pop-up window and type the template as specified below.
Say: {{#each var.name}}
   {{id}} {{Name}} -{{#with (lookup ../var.mark [id])}} {{Result}}.
Performance {{status}}.
    {{/with}}
{{/each}}

A Breakdown of the Template’s Structure

In this tutorial we use ‘each loop‘ to get ‘id’ and ‘Name’ from ‘var.name’ and use the ‘id’ from it to lookup in ‘var.mark’ for  both ‘Result’ and ‘status’. For the execution of this task we use, ‘lookup’ function. The following punctuation marks ‘../’ are used in lookup because ‘var.mark’ is outside the scope of ‘each loop’. Furthermore, the ‘id’ is placed inside a square bracket because we use the ‘id’ from ‘var.name’, which is an array.

To add a display message in a video-enabled voice-assisted device

1. Click on the Computer icon, and type in a condensed version of the voice message in the field titled Display Message of the Show pop-up window.
2. Populate the required fields and click the Save button. 
Title: Results
Display Message: {{#each var.name}}
   {{id}} {{Name}} -{{#with (lookup ../var.mark [id])}} {{Result}}.
Performance {{status}}.
    {{/with}}
{{/each}}

The screenshot below captures the aforementioned interaction flow.

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 the Name field of the Test Response window that shows up.
4. In the Conversation section of the Test Response, Lookup intent through which this interaction flow has been initiated will be auto-generated in the User invokes field.
5. Click the plus button within the Conversation section to open up an additional field titled User Invokes. Ensure to populate this field by selecting the Next intent called to action within the interaction flow.

6. Finally, click the Save button to perform the test.
7. To validate the Test Response, click on the lightning symbol on the left-hand side of the test case.

8. On the resultant Test Response window, the blue chat bubbles present the input message within the Response component.

9. Click on the chat bubble to see the details of the response.

To know more about testing an interaction refer https://university.vogovoice.com/kb/testings/

Congratulations! You have successfully created a custom interaction model by making use of the lookup function to retrieve the performance status of students using their ID. On the whole, you have designed an interaction flow that is efficiently tailored and curated with voice responses to suit the specific requirements of the end-user. 

👍 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/

To learn more about Lookup Function, click here.

Tags:
Was this article helpful?
Dislike 0
Previous: Subexpression and its Significance
Next: Learn More