Skip to content

Commit 2c0fb34

Browse files
committed
Enhancements and fixes to Get Emergency Contacts Scenario
1 parent 0a1ef49 commit 2c0fb34

2 files changed

Lines changed: 99 additions & 20 deletions

File tree

EmployeeSelfServiceAgent/Workday/EmployeeScenarios/WorkdayManageEmergencyContact/msdyn_HRWorkdayHCMEmployeeGetEmergencyContactInfo.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</endpoint>
1212
<responseProperties>
1313
<property>
14-
<extractPath>//*[local-name()='Related_Person_Data']//*[local-name()='Related_Person']</extractPath>
14+
<extractPath>//*[local-name()='Related_Person_Data']/*[local-name()='Related_Person'][*[local-name()='Emergency_Contact']]</extractPath>
1515
<key>EmergencyContacts</key>
1616
</property>
1717
</responseProperties>

EmployeeSelfServiceAgent/Workday/EmployeeScenarios/WorkdayManageEmergencyContact/topic.yaml

Lines changed: 98 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,13 @@ kind: AdaptiveDialog
22
inputs:
33
- kind: AutomaticTaskInput
44
propertyName: InputAction
5-
description: "Look for keywords 'add', 'new', or 'create' in the user's request. If found, extract 'add'. Otherwise extract 'manage'."
5+
description: "Look for keywords 'add', 'new', or 'create' in the user's request. If found, extract 'add'. Look for keywords 'get', 'view', 'show', 'list', 'see', 'display', or 'what are' in the user's request. If found, extract 'get'. Otherwise extract 'manage'."
66
entity: StringPrebuiltEntity
77
shouldPromptUser: false
88

99
modelDescription: |-
10-
You will respond to requests related to managing emergency contacts for the user making the request.
11-
This includes adding new emergency contacts or updating existing ones.
12-
All emergency contact operations are submitted to Workday (Human_Resources) and pertain exclusively to the requesting user.
13-
This data exclusively belongs to the user making the request. Do not respond to questions about other people's data.
14-
15-
Example invalid requests:
16-
"Manage emergency contact for my manager"
17-
"Update emergency contact for my colleague"
18-
19-
Example valid requests:
20-
"Manage my emergency contacts"
21-
"Update my emergency contact"
22-
"Add or update emergency contact"
23-
"Change my emergency contact information"
24-
"Add a new emergency contact"
10+
Manage emergency contacts for the requesting user only. Supports add and update via Workday (Human_Resources). Reject requests about other people's data.
11+
Formatting: ALWAYS display contacts in a markdown table with columns: Name, Relationship, Phone, Address. Mark primary with ★. Sort primary first, then by priority. Use "—" for missing fields. Heading: "Your emergency contacts" with divider. Never use bullet lists. Hide internal IDs (WID, Priority number, Country Codes). Show ALL contacts.
2512
beginDialog:
2613
kind: OnRecognizedIntent
2714
id: main
@@ -64,12 +51,18 @@ beginDialog:
6451

6552
dialog: msdyn_copilotforemployeeselfservicehr.topic.GetReferenceData
6653

54+
# Detect if user wants to view contacts only (get/view/show/list)
55+
- kind: SetVariable
56+
id: set_is_view_only
57+
variable: Topic.isViewOnly
58+
value: =(!IsBlank(Topic.InputAction) && "get" in Lower(Topic.InputAction)) || "get" in Lower(System.Activity.Text) || "view" in Lower(System.Activity.Text) || "show" in Lower(System.Activity.Text) || "list" in Lower(System.Activity.Text) || "see my" in Lower(System.Activity.Text) || "what are" in Lower(System.Activity.Text) || "display" in Lower(System.Activity.Text)
59+
6760
# Check if user explicitly wants to add a new contact - skip loading existing contacts
6861
- kind: ConditionGroup
6962
id: check_direct_add
7063
conditions:
7164
- id: user_wants_add_directly
72-
condition: =(!IsBlank(Topic.InputAction) && "add" in Lower(Topic.InputAction)) || "add" in Lower(System.Activity.Text) || "new emergency contact" in Lower(System.Activity.Text) || "create" in Lower(System.Activity.Text)
65+
condition: =Topic.isViewOnly <> true && ((!IsBlank(Topic.InputAction) && "add" in Lower(Topic.InputAction)) || "add" in Lower(System.Activity.Text) || "new emergency contact" in Lower(System.Activity.Text) || "create" in Lower(System.Activity.Text))
7366
displayName: User wants to add a new contact directly
7467
actions:
7568
- kind: SetVariable
@@ -227,7 +220,10 @@ beginDialog:
227220
variable: Topic.contactSelectionList
228221
value: |
229222
=ForAll(
230-
Topic.parsedContacts.EmergencyContacts,
223+
Filter(
224+
Topic.parsedContacts.EmergencyContacts,
225+
!IsBlank(LookUp(ThisRecord.Emergency_Contact.Emergency_Contact_Reference.ID, '@type' = "WID").'#text')
226+
),
231227
{
232228
DisplayName: ThisRecord.Personal_Data.Name_Data.Legal_Name_Data.Name_Detail_Data.'@Formatted_Name',
233229
FirstName: ThisRecord.Personal_Data.Name_Data.Legal_Name_Data.Name_Detail_Data.First_Name,
@@ -277,10 +273,93 @@ beginDialog:
277273
variable: Topic.WorkdayUrl
278274
value: https://impl.workday.com/<TENANT_NAME>/home.htmld
279275

276+
- kind: SetVariable
277+
id: build_contact_table
278+
displayName: Build formatted contact table
279+
variable: Topic.contactTableText
280+
value: |
281+
="| Name | Relationship | Phone | Address |" & Char(10) & "|------|-------------|-------|---------|" & Char(10) & Concat(
282+
SortByColumns(Topic.contactSelectionList, "IsPrimary", SortOrder.Descending, "Priority", SortOrder.Ascending),
283+
"| " & If(!IsBlank(ThisRecord.DisplayName), ThisRecord.DisplayName, "Unknown") & If(ThisRecord.IsPrimary = "true" || ThisRecord.IsPrimary = "1", " ★", "") & " | " & If(!IsBlank(ThisRecord.RelationshipType), ThisRecord.RelationshipType, "—") & " | " & If(!IsBlank(ThisRecord.Phone), ThisRecord.Phone, "—") & " | " & If(!IsBlank(ThisRecord.Address), ThisRecord.Address, "—") & " |",
284+
Char(10)
285+
)
286+
287+
# View-only mode: show table as Adaptive Card (full width) and end
288+
- kind: ConditionGroup
289+
id: check_view_only
290+
conditions:
291+
- id: is_view_only_mode
292+
condition: =Topic.isViewOnly = true
293+
displayName: User only wants to view contacts
294+
actions:
295+
- kind: SetVariable
296+
id: set_view_intro_text
297+
variable: Topic.viewIntroText
298+
value: ="Here are your emergency contacts from [Workday](" & Topic.WorkdayUrl & "), an HR platform your company uses."
299+
300+
- kind: SendActivity
301+
id: view_only_intro
302+
activity: "{Topic.viewIntroText}"
303+
304+
- kind: SendActivity
305+
id: view_only_table_card
306+
activity:
307+
attachments:
308+
- kind: AdaptiveCardTemplate
309+
cardContent: |-
310+
={
311+
type: "AdaptiveCard",
312+
'$schema': "http://adaptivecards.io/schemas/adaptive-card.json",
313+
version: "1.3",
314+
body: [
315+
{
316+
type: "TextBlock",
317+
text: "Your emergency contacts (" & Text(CountRows(Topic.contactSelectionList)) & ")",
318+
weight: "Bolder",
319+
size: "Medium",
320+
wrap: true
321+
},
322+
{
323+
type: "ColumnSet",
324+
separator: true,
325+
spacing: "Medium",
326+
columns: [
327+
{ type: "Column", width: 2, items: [{ type: "TextBlock", text: "Name", weight: "Bolder", wrap: true }] },
328+
{ type: "Column", width: 2, items: [{ type: "TextBlock", text: "Relationship", weight: "Bolder", wrap: true }] },
329+
{ type: "Column", width: 2, items: [{ type: "TextBlock", text: "Phone", weight: "Bolder", wrap: true }] },
330+
{ type: "Column", width: 3, items: [{ type: "TextBlock", text: "Address", weight: "Bolder", wrap: true }] }
331+
]
332+
},
333+
{
334+
type: "Container",
335+
items: ForAll(
336+
SortByColumns(Topic.contactSelectionList, "IsPrimary", SortOrder.Descending, "Priority", SortOrder.Ascending),
337+
{
338+
type: "ColumnSet",
339+
separator: true,
340+
columns: [
341+
{ type: "Column", width: 2, items: [{ type: "TextBlock", text: If(!IsBlank(ThisRecord.DisplayName), ThisRecord.DisplayName, "Unknown") & If(ThisRecord.IsPrimary = "true" || ThisRecord.IsPrimary = "1", " ★", ""), wrap: true }] },
342+
{ type: "Column", width: 2, items: [{ type: "TextBlock", text: If(!IsBlank(ThisRecord.RelationshipType), ThisRecord.RelationshipType, "—"), wrap: true }] },
343+
{ type: "Column", width: 2, items: [{ type: "TextBlock", text: If(!IsBlank(ThisRecord.Phone), ThisRecord.Phone, "—"), wrap: true }] },
344+
{ type: "Column", width: 3, items: [{ type: "TextBlock", text: If(!IsBlank(ThisRecord.Address), ThisRecord.Address, "—"), wrap: true }] }
345+
]
346+
}
347+
)
348+
}
349+
]
350+
}
351+
352+
- kind: SendActivity
353+
id: view_only_footer
354+
activity: "If you need to update or add any information for these contacts, just let me know which one you'd like to change or if you want to add a new contact."
355+
356+
- kind: CancelAllDialogs
357+
id: end_view_only
358+
280359
- kind: SetVariable
281360
id: set_intro_msg_text
282361
variable: Topic.introMsgText
283-
value: ="Sure, I can help you with that. Here's where you can both update and add emergency contacts. I've identified " & Text(CountRows(Topic.selectionChoices)) & " emergency contact(s) of yours from [Workday](" & Topic.WorkdayUrl & "), an HR platform your company uses."
362+
value: ="Sure, I can help you with that. Here's where you can update and add emergency contacts. I've identified " & Text(CountRows(Topic.selectionChoices)) & " emergency contact(s) of yours from [Workday](" & Topic.WorkdayUrl & "), an HR platform your company uses."
284363

285364
- kind: SendActivity
286365
id: intro_selection_msg

0 commit comments

Comments
 (0)