One of the things I love most about the Power Platform is how quickly you can build a solution to a problem using a little bit of low code magic.
I have been working on a Power App with a colleague and we were casually chatting in teams about it. We agreed that we should have a meeting to run through some of the last few items on the backlog before we get it into testing and production.
Both of our calendars are pretty busy and so I had a bit of a lightbulb moment. Why can't you quickly send a list of options to your colleague for them to pick a time that works for them when you're both free...
Sure, I could use the create a meeting, but even the scheduling assistant assumes the time you choose is their preferred time.
So, off to work I went and built a nice little add in that allows you to do just that!
Getting the Workflow Ready
First, I click on the chat ellipsis, go to 'More actions' and then 'Create new action'.
My trigger for this workflow is to run 'For a selected message'.
Then I am going to get the message details, using the dynamic fields Message ID and Conversation ID for the Group chat.
Next, I want to get some of the user details to use in the workflow, so I am using the Office 365 connectors 'Get my profile (V2)' and 'Search for users (V2)'.
Now I have the message details and the users involved in the chat I need to move on to the next stage of my workflow!
Finding our availability
To find the availability of the users in the chat, I need to use the Find meeting times (V2) action. As I input the emails for myself and the user, I am chatting to it will create an apply to each loop. There are ways to get around this but for now this will do.
First I need to create a variable to store the available times so I do a quick Initialize variable action:
I want the tool/workflow to find times from 'now' and up to 10 days in advance. I know that my outlook will only schedule during working hours so I don't need to worry about weekends here.
I have two expressions:
utcNow()
addDays(utcNow(),10)
Building the adaptive card
Now I need to build an adaptive card so that the person I am chatting to can select a list of available dates.
First I use the compose function to get my variable into a usable function. The I use the Select function to build my choice list.
I wanted my dates and times to be user friendly so I added in two functions here
formatDateTime(item()?['start']?['dateTime'],'dddd dd MMMM hh:mm tt')
Separate them with a dash
formatDateTime(item()?['end']?['dateTime'],'hh:mm tt')
For the value I am choosing the start.ddateTime dynamic value as I want to use this when booking in the meeting.
Next I need to create an Array to put the choices that have been formatted into the JSON for the adaptive card. This is the body of the Select function
body('Select')
Next I am going to choose the Post an adaptive card and wait for a response action
The body for the adaptive card is below but make sure to put in your variable for the choices.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": "Meeting Poll Request",
"id": "Title",
"spacing": "Medium",
"horizontalAlignment": "Center",
"size": "ExtraLarge",
"weight": "Bolder",
"color": "Accent"
},
{
"type": "TextBlock",
"text": "Let's find a time to meet!",
"id": "acHeaderTagLine",
"separator": true
},
{
"type": "TextBlock",
"text": "Hi, I've checked our calendars and here are some times we can meet",
"id": "acInstructions",
"wrap": true
},
{
"type": "TextBlock",
"text": "Meeting Poll",
"id": "acPollQuestion"
},
{
"type": "Input.ChoiceSet",
"placeholder": "Select from these choices",
"choices": @{variables('VarMeetingChoices')},
"id": "acPollChoices",
"style": "expanded"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Submit",
"id": "btnSubmit"
}
]
}
Next I am using the Parse JSON action to get the bits I need from the response of the adaptive card.
The Content in the below is the body of the adaptive card action.
I have pasted the Schema below for speed if building this yourself.
{
"type": "object",
"properties": {
"responseTime": {
"type": "string"
},
"responder": {
"type": "object",
"properties": {
"objectId": {
"type": "string"
},
"tenantId": {
"type": "string"
},
"email": {
"type": "string"
},
"userPrincipalName": {
"type": "string"
},
"displayName": {
"type": "string"
}
}
},
"submitActionId": {
"type": "string"
},
"messageId": {
"type": "string"
},
"messageLink": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"acPollChoices": {
"type": "string"
}
}
}
}
}
Getting the meeting booked in
The last step is to automatically book the meeting in when the user has selected an option. I have added in a few bits to make the invite useful, such as adding in a link to the chat in Teams that caused us to need this meeting.
The start time you can get from the 'acPollChoices' dynamic content
Testing it out
So, now when I am chatting to a user I can click on my new action
It sends an adaptive card to the user
And finally, the meeting booked in our calendars
Commentaires