Exercise 3 - Test the Holiday list request service from IBM Watson Assistant
With the record and process definitions built for this service, the next step is to see how to create Watson Dialogs to invoke the Get Country HR Source Data process.
Intent:
From IBM Watson select the HR Chatbot skill and go the Intents section. The #BMC_Holiday_List intent, was created for this service. The intent comes with 12 values or utterances.
For more information about these values, please review them using your IBM Watson Assistant instance where this service has been published to, because we have not documented every aspect of the intents here.
Tip: The number of Intent utterances will vary based on the use case. In this use case, the main goal is to request a holiday list for a given country and year. The following are some sample intent utterances that can be used to build out the Intent values:
- Can I get the holiday list for the United States
- Can I get the list of holidays for the United States
- holiday calendar
- holiday calendar for Spain
- holiday list in Malaysia
- list of holidays
- list of holidays in Canada
- upcoming holidays in Mexico
- What are the holidays for Puerto Rico
- when can I plan vacation
- when is the next holiday?
- when is the upcoming holidays in South Africa
Entities:
For this service we created one new entity and used @sys-date system entity.
@bmc_country
- This entity stores country names. To view the list of countries for this entity, review it by using your IBM Watson Assistant instance where this service has been created, because we have not documented this information here.
@sys-date:
- This is System entity. For more information about this system entity please refer to the following link: https://cloud.ibm.com/docs/assistant?topic=assistant-system-entities#system-entities-sys-date-time
Dialog Nodes:
Tip: When creating a new service that was not created by using the Chatbot publishing wizard, it is recommended to copy an existing dialog node that is like your service use case to get the needed JSON content. (Note: you can use the dialog nodes that come with this starter kit for this purpose)
In HR Chatbot skill go to the Dialog section and look for the BMC - Holiday List dialog. This is the parent dialog for this service. We have added the intent #BMC_Holiday_List in the condition, so that when Watson identifies this intent the parent dialog for this service gets triggered.
One difference that you will see here is we don't have any questionnaire for this service. If the requester doesn't enter any country, then requester's Innovation Studio Foundation data country is used.
Next, we will look at the JSON created for this service. From the BMC - Holiday List dialog node, click on the three vertical dots as seen from the highlighted section in the screenshot below.
Under context section you will see few a variable that are initialized.
- "bmc_holiday_year": "<? @sys-date ? @sys-date.substring(0,4) : null ?>" If you provide a year in the input then sys-date.substring IBM Watson function is used to extract the year from @sys-date. If @sys-date is not identified, then a null value is sent to process and it is calculated in the Innovation Studio Process
- "bmc_holiday_country": "<?@bmc_country ? @bmc_country.values.join(' ') : $chatbot_country?>" Here we set the country in $ bmc_holiday_country variable. If country is specified in user text then its extracted and stored, otherwise the foundation country, which is in $chatbot_country variable, is stored into $ bmc_holiday_country. @bmc_holiday_country.values returns an array , the join function is used to display the two name element values from the array as a String
- "bmc_hr_activity": "Holiday"We have set the activity value to the $bmc_hr_activity variable. The same value is used to compare with the record entry activity field in process
Under the action section of the JSON you will see the following:
- inputMap: this is where we define the mapping between the process input variables, represented by their field IDs, to the Watson context variables
- outputMap: this is where we define the mapping between the process output variable, represented by their field IDs, to the Watson context variables
- processDefinitionName: this is where we define the process that will be executed from Innovation Studio for this service. When the process in the output action map is executed, the process result is embedded in the user message and sent to the user. If you want to return a process result to Watson for validation or conditional child dialog execution, you must use "waitForActionExecution": true in the output action map.
When status of the process is "Success", then the Holiday list is presented along with the message "Here are the holidays in $bmc_holiday_country in $bmc_holiday_year <br> $bmc_holiday_list".
Note: In above message we have used html <br> tag to display holiday list on new line.
The $bmc_holiday_country, $bmc_holiday_year and $bmc_holiday_list variables will be replaced with actual values. If we don't get the holiday list from process, then we display "I couldn't find a list of holidays for $bmc_holiday_country.for $bmc_holiday_year" message to the user.