diff --git a/copilot-studio/office-365-users-get-manager-topic/README.md b/copilot-studio/office-365-users-get-manager-topic/README.md new file mode 100644 index 0000000..7a0ee44 --- /dev/null +++ b/copilot-studio/office-365-users-get-manager-topic/README.md @@ -0,0 +1,65 @@ +# Office 365 Users: Get Manager + +This is a snippet that demonstrates how to get the manager of any user using the Office 365 Users connector inside of a Copilot Studio topic. + +![Office 365 Users: Get Manager topic in chat](./assets/office-365-users-get-manager-topic-chat.png) + +## Minimal path to awesome + +### Add the action + +1. Open a copilot in **Copilot Studio** +1. Select **Actions** +1. Select **+ Add an action** +1. Search for **Get manager** and press _Enter_ +1. Select the **Get manager (V2)** action from the **Office 365 Users** connector +1. Select **Next** +1. Select **Next** again +1. Select **Finish** +1. Select the **Office 365 Users - Get manager (V2)** action in the list (select the name) +1. Select the **...** in the upper right corner and select **Open code editor** +1. Make sure to look for and copy the **name** of the **connection reference** + + ![Connection reference name](./assets/connection-reference-name.png) + +1. Paste the contents of the **[YAML-file](./source/manager.yaml)** into the code editor +1. Replace **{ REPLACE-WITH-CONNECTION-REFERENCE-NAME }** with the **connection reference name** you copied two steps earlier +1. Now copy the first part of the **connection reference name**, up to the first period (.) + + ![Internal name of Copilot](./assets/internal-name.png) + + This is the **internal name of your copilot**. You'll need it later. + +1. **Save** the action +1. Select **Settings** +1. Select **Generative AI** +1. Scroll down to **How should your copilot decide how to respond?** and enable the **Generative** option +1. Select **Save** +1. Exit **Settings** by selecting the **X** in the upper right corner + +### Configure the topic + +1. Select **Topics** +1. Select **+ Add a topic** +1. Select **From blank** +1. Name the topic **Get Manager Details** +1. Select the **...** in the upper right corner and select **Open code editor** +1. Paste the contents of the **[YAML-file](./source/topic.yaml)** into the code editor +1. Replace all references of **{ REPLACE-WITH-INTERNAL-COPILOT-NAME }** with the **internal name of the copilot** you copied earlier (There are 4 references) +1. Select **Save** + + You may see the following warning: + + ![Warning](./assets/warning.png) + + Ignore this and select **Save**. There are no errors as long as you've replaced all references of the **internal name of the copilot** correctly + + To ensure that there are no errors, once the topic has been saved, select **Topic checker** and you should see the following: + + ![Topic checker](./assets/topic-checker.png) + +1. Test out the copilot by asking **_"Who's my manager?"_** in the chat and follow the prompts. + + You should then get the following result (with your manager's name): + + ![My manager result](./assets/my-manager-result.png) \ No newline at end of file diff --git a/copilot-studio/office-365-users-get-manager-topic/assets/connection-reference-name.png b/copilot-studio/office-365-users-get-manager-topic/assets/connection-reference-name.png new file mode 100644 index 0000000..98a30f5 Binary files /dev/null and b/copilot-studio/office-365-users-get-manager-topic/assets/connection-reference-name.png differ diff --git a/copilot-studio/office-365-users-get-manager-topic/assets/internal-name.png b/copilot-studio/office-365-users-get-manager-topic/assets/internal-name.png new file mode 100644 index 0000000..3309b0b Binary files /dev/null and b/copilot-studio/office-365-users-get-manager-topic/assets/internal-name.png differ diff --git a/copilot-studio/office-365-users-get-manager-topic/assets/my-manager-result.png b/copilot-studio/office-365-users-get-manager-topic/assets/my-manager-result.png new file mode 100644 index 0000000..c55bd75 Binary files /dev/null and b/copilot-studio/office-365-users-get-manager-topic/assets/my-manager-result.png differ diff --git a/copilot-studio/office-365-users-get-manager-topic/assets/office-365-users-get-manager-topic-chat.png b/copilot-studio/office-365-users-get-manager-topic/assets/office-365-users-get-manager-topic-chat.png new file mode 100644 index 0000000..01ea0e6 Binary files /dev/null and b/copilot-studio/office-365-users-get-manager-topic/assets/office-365-users-get-manager-topic-chat.png differ diff --git a/copilot-studio/office-365-users-get-manager-topic/assets/topic-checker.png b/copilot-studio/office-365-users-get-manager-topic/assets/topic-checker.png new file mode 100644 index 0000000..7e684cc Binary files /dev/null and b/copilot-studio/office-365-users-get-manager-topic/assets/topic-checker.png differ diff --git a/copilot-studio/office-365-users-get-manager-topic/assets/warning.png b/copilot-studio/office-365-users-get-manager-topic/assets/warning.png new file mode 100644 index 0000000..9efcf9a Binary files /dev/null and b/copilot-studio/office-365-users-get-manager-topic/assets/warning.png differ diff --git a/copilot-studio/office-365-users-get-manager-topic/source/manager.yaml b/copilot-studio/office-365-users-get-manager-topic/source/manager.yaml new file mode 100644 index 0000000..5faa045 --- /dev/null +++ b/copilot-studio/office-365-users-get-manager-topic/source/manager.yaml @@ -0,0 +1,79 @@ +kind: TaskDialog +inputs: + - kind: AutomaticTaskInput + propertyName: id + description: User principal name or id or email address + entity: StringPrebuiltEntity + +outputs: + - propertyName: aboutMe + + - propertyName: accountEnabled + + - propertyName: birthday + + - propertyName: businessPhones + + - propertyName: city + + - propertyName: companyName + + - propertyName: country + + - propertyName: department + + - propertyName: displayName + + - propertyName: givenName + + - propertyName: hireDate + + - propertyName: id + + - propertyName: interests + + - propertyName: jobTitle + + - propertyName: mail + + - propertyName: mailNickname + + - propertyName: mobilePhone + + - propertyName: mySite + + - propertyName: officeLocation + + - propertyName: pastProjects + + - propertyName: postalCode + + - propertyName: preferredLanguage + + - propertyName: preferredName + + - propertyName: responsibilities + + - propertyName: schools + + - propertyName: skills + + - propertyName: state + + - propertyName: streetAddress + + - propertyName: surname + + - propertyName: userPrincipalName + + - propertyName: userType + +action: + kind: InvokeConnectorTaskAction + connectionReference: { REPLACE-WITH-CONNECTION-REFERENCE-NAME } + connectionProperties: + mode: Invoker + + operationId: Manager_V2 + +triggerCondition: false \ No newline at end of file diff --git a/copilot-studio/office-365-users-get-manager-topic/source/topic.yaml b/copilot-studio/office-365-users-get-manager-topic/source/topic.yaml new file mode 100644 index 0000000..c6c6270 --- /dev/null +++ b/copilot-studio/office-365-users-get-manager-topic/source/topic.yaml @@ -0,0 +1,236 @@ +kind: AdaptiveDialog +modelDescription: Gets the manager details of any user +beginDialog: + kind: OnRecognizedIntent + id: main + intent: {} + actions: + - kind: SendActivity + id: sendActivity_mOFgma + activity: Let's get those details for you 😊 + + - kind: Question + id: question_4MfIos + interruptionPolicy: + allowInterruption: true + + variable: init:Topic.userChoice + prompt: To confirm - are we trying to get the details of your manager or a colleague's manager? + entity: + kind: EmbeddedEntity + definition: + kind: ClosedListEntity + items: + - id: My manager + displayName: My manager + + - id: My colleague's manager + displayName: My colleague's manager + + - kind: ConditionGroup + id: conditionGroup_WUd83N + conditions: + - id: conditionItem_IDEXaI + condition: =Topic.userChoice = '{ REPLACE-WITH-INTERNAL-COPILOT-NAME }.topic.GetManagerDetails.main.question_4MfIos'.'My manager' + actions: + - kind: Question + id: question_m3ehQc + interruptionPolicy: + allowInterruption: true + + variable: init:Topic.userEmail + prompt: What's your email address? + entity: StringPrebuiltEntity + + - kind: BeginDialog + id: FttvwJ + input: + binding: + id: =Topic.userEmail + + dialog: { REPLACE-WITH-INTERNAL-COPILOT-NAME }.component.Office365Users-GetmanagerV2 + output: + binding: + aboutMe: Topic.aboutMe + accountEnabled: Topic.accountEnabled + birthday: Topic.birthday + businessPhones: Topic.businessPhones + city: Topic.city + companyName: Topic.companyName + country: Topic.country + department: Topic.department + displayName: Topic.displayName + givenName: Topic.givenName + hireDate: Topic.hireDate + id: Topic.id + interests: Topic.interests + jobTitle: Topic.jobTitle + mail: Topic.mail + mailNickname: Topic.mailNickname + mobilePhone: Topic.mobilePhone + mySite: Topic.mySite + officeLocation: Topic.officeLocation + pastProjects: Topic.pastProjects + postalCode: Topic.postalCode + preferredLanguage: Topic.preferredLanguage + preferredName: Topic.preferredName + responsibilities: Topic.responsibilities + schools: Topic.schools + skills: Topic.skills + state: Topic.state + streetAddress: Topic.streetAddress + surname: Topic.surname + userPrincipalName: Topic.userPrincipalName + userType: Topic.userType + + - kind: SendActivity + id: sendActivity_ULgds4 + activity: + attachments: + - kind: AdaptiveCardTemplate + cardContent: |- + ={ + type: "AdaptiveCard", + body: [ + { + type: "TextBlock", + text: "Your manager is", + wrap: true + }, + { + type: "ColumnSet", + columns: [ + { + type: "Column", + items: [ + { + type: "TextBlock", + weight: "Bolder", + text: Topic.displayName, + wrap: true + }, + { + type: "TextBlock", + spacing: "None", + text: Topic.jobTitle, + isSubtle: true, + wrap: true + } + ], + width: "stretch" + } + ] + } + ], + '$schema': "http://adaptivecards.io/schemas/adaptive-card.json", + version: "1.3" + } + + - id: conditionItem_zsm8vP + condition: =Topic.userChoice = '{ REPLACE-WITH-INTERNAL-COPILOT-NAME }.topic.GetManagerDetails.main.question_4MfIos'.'My colleague''s manager' + actions: + - kind: Question + id: question_EjT7mU + interruptionPolicy: + allowInterruption: true + + variable: init:Topic.colleagueName + prompt: What is your colleague's name? + entity: StringPrebuiltEntity + + - kind: Question + id: question_AHWowM + interruptionPolicy: + allowInterruption: true + + variable: Topic.userEmail + prompt: What's {Topic.colleagueName}'s email address? + entity: StringPrebuiltEntity + + - kind: BeginDialog + id: vvYdU0 + input: + binding: + id: =Topic.userEmail + + dialog: { REPLACE-WITH-INTERNAL-COPILOT-NAME }.component.Office365Users-GetmanagerV2 + output: + binding: + aboutMe: Topic.aboutMe + accountEnabled: Topic.accountEnabled + birthday: Topic.birthday + businessPhones: Topic.businessPhones + city: Topic.city + companyName: Topic.companyName + country: Topic.country + department: Topic.department + displayName: Topic.displayName + givenName: Topic.givenName + hireDate: Topic.hireDate + id: Topic.id + interests: Topic.interests + jobTitle: Topic.jobTitle + mail: Topic.mail + mailNickname: Topic.mailNickname + mobilePhone: Topic.mobilePhone + mySite: Topic.mySite + officeLocation: Topic.officeLocation + pastProjects: Topic.pastProjects + postalCode: Topic.postalCode + preferredLanguage: Topic.preferredLanguage + preferredName: Topic.preferredName + responsibilities: Topic.responsibilities + schools: Topic.schools + skills: Topic.skills + state: Topic.state + streetAddress: Topic.streetAddress + surname: Topic.surname + userPrincipalName: Topic.userPrincipalName + userType: Topic.userType + + - kind: SendActivity + id: sendActivity_bLVv2l + activity: + attachments: + - kind: AdaptiveCardTemplate + cardContent: |- + ={ + type: "AdaptiveCard", + body: [ + { + type: "TextBlock", + text: Topic.colleagueName & "'s manager is", + wrap: true + }, + { + type: "ColumnSet", + columns: [ + { + type: "Column", + items: [ + { + type: "TextBlock", + weight: "Bolder", + text: Topic.displayName, + wrap: true + }, + { + type: "TextBlock", + spacing: "None", + text: Topic.jobTitle, + isSubtle: true, + wrap: true + } + ], + width: "stretch" + } + ] + } + ], + '$schema': "http://adaptivecards.io/schemas/adaptive-card.json", + version: "1.3" + } + + elseActions: + - kind: EndConversation + id: rw5Xcc \ No newline at end of file