VOGO Voice – Knowledge Base

Every nth Time (Using MOD feature)

Estimated reading time: 13 min

MOD, short for modulo in math operation is one which returns the remainder after a number is divided by a divisor. Being part of the modular arithmetic, it is commonly used in nearly all programming languages. 

This user-centric tutorial which is an extension of the Tutorial on Visitor Counter will provide an instructional step-by-step walkthrough on how to define the MOD feature within an interaction flow initiated via the Launch interaction to execute Every nth Time logic in a custom interaction model. The purpose here being to prompt the curated voice responses at specific intervals and enhance the user’s experience of the functionality of the skill. 

Prerequisites

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

Steps to create a custom intent

This advanced tutorial focuses on how to build a custom interaction model that will logically prompt the existing user with specific questions or the like at fixed intervals or Every nth Time.

To illustrate the aforementioned, the question made use of in this interaction flow will be How old are you? To have this question prompted to the returning user Every nth time, we have to create a custom intent to be invoked through the skill every time the logic of the MOD function implemented in the Add Variables component satisfies the test condition specified in the Check Variable component. 

Hence, create a custom intent titled “How old are you” with a set of suitable sample utterances mapped to it.  Let’s say the sample utterances are: “I am {age} years old”, “I am {age}”, “I will be {age} soon” where “age” is the slot name. Assign the slot type to ENVIRONMENT_Number, which is a global slot with predefined values.

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 how Every nth Time can be used by means of the MOD feature to prompt something every 5th time for example.  

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.
Dashboard > Interactions
3.Click on the Open button of the default Launch interaction card 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.Unlink the Start component from the Response card by clicking the delete icon placed in the middle of the chain.

6.Drag and drop the Check variable component onto the flow diagram area.
7.Connect the the Start component to the Check Variable component.

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

8. Configure the Check Variable component with a test condition using the relational operator Exists to evaluate the value stored in the system through Save Settings. The flow for the existing user will proceed from Then because the values of his previous visit exists; and for the new user it will progress from Otherwise as no values are existent in the system.
1. Populate the left hand side of the Configuration window as in the screenshot shown below. Set the data type based on the input.

Left-Hand side: settings.visitorCnt (choose data type as Path).

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

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

9.Drag and drop the Save Settings component onto the flow canvas. 

10.Chain the Then on the Check Variable component to the Save Settings component. The objective of configuring the Save Settings component here is to first implement the counter function within the skill to capture the instance of the user’s visit for the purpose of returning a numerical value upon his next visit in the form of a voice response. This function when called to action adds value one (+1) to the instance of the user’s previous visit represented by a numerical value within the Save Settings component.

11.To configure the Save Settings component add the key-value pair. Input visitorCnt as the key and add as its corresponding value. Set the data type as Function. There’s also another way to input the value add and its corresponding type as Function – navigate to the Data tab adjacent to the Components on the top left-hand side of the interaction builder platform. 

1.In the Data section navigate further down through to Functions. Click on its plus button to have its subsection appear. In the list that appears, click on the plus button of Math which will open up a list. From the list select add by dragging and dropping it in the value field of the Save Settings component which will automatically generate add and Function in its respective fields.

2. Then input the first argument by clicking the plus button that appears under the heading Arguments.

3. Input number to represent the numerical value and set the data type to Function as shown below.

4. Click on the plus button that comes within the Arguments. In this sub-section add the path to which the value is saved. Here the input being settings.visitorCnt. Choose the data type as Path.
5. Now click on the plus button as highlighted in the screenshot below that appears on the region outside of the subsection to add a second argument. The purpose here being to substantiate the first argument.

6. Populate the field that appears with the numerical value 1 and choose its data type as Number.

12.Now drag and drop another Save Settings component onto the flow canvas.
13.Chain the anchor symbol of Otherwise on the Check Variable component to the the Save Settings component.

14. Configure the Save Settings component by adding the key-value pair. 
1. To configure add an arbitrary variable name to identify the value stored and assign a corresponding value to be called to function anytime within or beyond a session. Here, the key represents the variable visitorCnt and the value assigned is 1 to capture and save the initial visit of the user. Set the data type to Number.

To know more about different data types, click here.

15.Drag and drop a Response component onto the flow canvas and link it to the Save Settings component attached to the Otherwise on the Check Variable Component.

16.Roll the mouse over the Response component to see the voice, computer and camera icon on the top right-hand side of the component.
17. Click on the Voice icon of the Response card to open up the Speak pop-up window and type the voice message welcoming the new user to the skill in the field titled Say.
Say: Welcome to the Vocabulary Bingo game.

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: Vocabulary Bingo
Display Message: Welcome to the Vocabulary Bingo game.

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

18. Now drag and drop another Check Variable component onto the flow canvas.
19. Connect this Check Variable component to the Save Settings component that has been attached to the Then of the previously configured Check Variable component.

20.Now configure the Check Variable component with a test condition using the relational operator is greater than to evaluate the value stored in the system through Save Settings.  Here the purpose being to curate two different voice responses based on the counter > 5 i.e. one to address a user whose visit to the skill has exceeded five times and the other one for a user who has visited the skill five times or lesser.
1. Populate the left-hand side and right-hand side of the Configuration window as in the screenshot shown below. Set the data type based on the input.
Left-Hand side: settings.visitorCnt (choose data type as Path).
Right-Hand side:  5 (choose data type as Number)

Upon testing the condition, the subsequent pathing will be modeled accordingly i.e. if the test condition returns true link the result to “Then” and if it returns false, link it to “Otherwise”. 

21. Drag and drop another Response component onto the flow canvas and link it to Otherwise on the Check Variable component.

22.Roll the mouse over the Response component to see the voice, computer and camera icon on the top right-hand side of the component.
23. Click on the Voice icon of the Response card to open up the Speak pop-up window and type the voice action intended to be spoken to the user in the field titled Say to provide a suitable response if the test condition returns false i.e. the Check Variable component upon evaluating the values stored in the system recognizes the number of times the user has visited the skill as 5 or less than 5.
 Say: Welcome back to the classic Vocabulary Bingo game! Glad to see you visit {{settings.visitorCnt}} times.   

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: Vocabulary Bingo
Display Message: Welcome back to the classic Vocabulary Bingo game! Glad to see you visit {
{settings.visitorCnt}} times. 

24. Now drag and drop another Check Variable component and link it to the Then on the preceding Check Variable component.

25.Configure the Check Variable component with a test condition using the relational operator Exists to check if the age of the user is saved within the system through Save Settings. The flow for the existing user will proceed from Then if the age of the user is existent; and the resultant flow will proceed from Otherwise if no values are existent in the system.
1. Populate the left hand side of the Configuration window as in the screenshot shown below. Set the data type based on the input.

  Left-Hand side: settings.Age (choose data type as Path)

26. Now drag and drop a Response component and link it to Then on the Check Variable component.

27. Roll the mouse over the Response component to see the voice, computer and camera icon on the top right-hand side of the component.
28.Click on the Voice icon of the Response card to open up the Speak pop-up window and type the voice action intended to be spoken to the user in the field titled Say to provide a suitable response if the test condition returns true i.e. if the user’s age is saved in the system.
Say: Welcome back to the classic Vocabulary Bingo game! Glad to see you visit  {{settings.visitorCnt}} times. It will be more fun this time as we have more games for your age.

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: Vocabulary Bingo
Display Message: Welcome back to the classic Vocabulary Bingo game! Glad to see you visit  {{settings.visitorCnt}} times. It will be more fun this time as we have more games for your age.

29. Drag and drop an Add Variables component onto the flow canvas and link it to the Otherwise of the preceding Check Variable component.

30. Configure the Add Variables component by adding the key-value pair as shown below. Set the data type as Function for the value mod and add the arguments settings.visitorCnt and 5 ( here, the number of times visited by the user saved in the settings.visitorCnt will be divided by the divisor 5). Furthermore, the mod value 5 also defines the intervals at which the nth Time feature will be triggered to say or ask something relevant to the user.  Choose the respective data types for the arguments settings.vistorCnt and 5 as Path and Number . 

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

31. Drag and drop another Check Variable component on the flow canvas.
32. Chain the anchor symbol of Next on the Add Variables component to the topmost anchor symbol on the Check Variable component. 

1.Configure the Check Variable with a test condition using the relational operator Is equal to to check if the value of MOD returns 0. Set the data type as Path for the value var.mod. Therefore, based on the condition specified, in all those instances when the number of visits of the user when divided by a divisor (which is input as 5 in the Add Variable component) gives the remainder(mod) as zero (0), the MOD feature gets executed to ask or say something relevant Every nth Time. For example, here in this interaction flow the MOD feature is used to query the user’s age every 5th Time. Also to be noted is that every time the divisor of 5 is used to divide the number of times the user has visited the skill, we get the remainder as 0 every 5th time. So, when the user’s count of visit reaches 10, 15, 20 respectively we get the remainder as 0 thereby successfully implementing the MOD feature by satisfying the condition specified in the Check Variable component as shown below.

Left-Hand Side: var.mod
Right-Hand Side: 0

33.Drag and drop two Response components onto the flow canvas and link one to Then and the other one to Otherwise on the Check Variable Component.

34. Configure the Response component linked to Then on the Check Variable component.
35. Roll the mouse over the Response component to see the voice, computer and camera icon on the top right-hand side of the component.
36. Click on the Voice icon of the Response card to open up the Speak pop-up window with a field titled Say wherein you need to type the voice message to be relayed to the existing user at an interval of every 5 times of his visit to the skill. The voice response would have to be framed accordingly to address an existing user whose age is not saved in the system.
Say: Welcome back to the Vocabulary Bingo game. We have many games that vary in length and complexity to suit different ages.
37. Check the checkmark box in the Expect Response and type in the suitable Prompt message to proceed with the flow.
Prompt: Can you tell me your age ? For example, you can say I am 10 years old.
The same message will be replicated in the Reprompt field which can be edited for brevity, if need be.
Reprompt: Can you tell me your age ? For example, you can say I am 10 years old.
38. Populate the field under Expectations by selecting the custom Intent How old are you from the drop-down list which will open up a slot titled age to capture the age of the user.

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: Vocabulary Bingo
    Display Message: Welcome back to the Vocabulary Bingo game. We have many games that vary in length and complexity to suit different ages.

39. Now configure the Response component linked to Otherwise on the Check Variable component.
40. Roll the mouse over the Response component to see the voice, computer and        camera icon on the top right-hand side of the component.
41. Click on the Voice icon of the Response card to open up the Speak pop-up window with a field titled Say wherein you need to type the voice message to be relayed to the existing user on all those instances when the MOD function is not executed.
Say: Glad to see you visit the Vocabulary Bingo game {{settings.visitorCnt}} times. We have over a hundred different games to suit everyone. 

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: Vocabulary Bingo
    Display Message: Glad to see you visit the Vocabulary Bingo game {{settings.visitorCnt}} times. We have over a hundred different games to suit everyone. 

42. Drag and drop a Save Settings component onto the flow canvas and connect the anchor symbol of How old are you on the Response component to the Save Settings component.

43. To configure the Save Settings component add the key-value pair. Populate Age as the key and inputs.age.value as its corresponding value. Set the data type as Path. 

44. Drag and drop another Response component on the flow diagram area and connect it to the Next on the configured Save Settings component. 

45. Roll the mouse over the Response component to see the voice, computer and        camera icon on the top right-hand side of the component.
46. Click on the Voice icon of the Response card to open up the Speak pop-up window with a field titled Say wherein you need to type the voice message to be relayed to the existing user when the MOD function gets executed at the nth Time, here being the fifth time as defined in the Check Variable component.
Say: Great! You are {{inputs.age.value}} years old. We have many games for your age.
47. Check the checkmark box in the Expect Response and type in the suitable Prompt message to proceed with the flow.
Prompt: You can try out more games by saying More games.
The same message will be replicated in the Reprompt field which can be edited for brevity, if need be.
Reprompt: You can try out more games by saying More games

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: Vocabulary Bingo
    Display Message: Great! You are {{inputs.age.value}} years old. We have many games for your age.

The screenshot below captures the aforementioned interaction flow

Testing and Validation

a)Testing for Existing User (MOD function)

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, the Launch intent through which this interaction flow has been initiated will be auto-generated in the User invokes field as shown below.
5.Populate the User Settings sectionfield with the variable as defined in the Save Settings component. Input the variable as visitorCnt andassign a numerical value representing the count of the number of times the user has visited the skill since his initial visit. Here the value assigned is 9, to which value one (+1) will be added to represent the total number of times the user has visited the skill i.e. to add the first instance of his visit to the value captured and stored in the system. The reason being the function of the counter is triggered upon the user’s second visit onwards.
6.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 How old are you intent called to action within the interaction flow.
1. Fill the “With slots” field titled age that appears under How old are you with the input value as 10.

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

9. On the resultant Test Response window, the blue chat bubble will present the input message within the Response component addressing the existing user the nth Time (5th) at which the MOD function was implemented.

10. Click on the chat bubble to see the details of the individual response. 

b) Testing for new user

Repeat the same steps as carried out while performing Testing for Existing User with the exception being to leave the additional User Invokes field and the  User Settings section empty as shown below.

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

Congratulations! You have successfully created an interaction flow by implementing the Every nth Time feature by using the MOD function.

👍 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 access the tutorial on Visitor Counter, click here.

Tags:
Was this article helpful?
Dislike 0
Previous: Age check
Next: Using Geocoder to Lookup Information