diff --git a/samples/Send-Inline-Image-In-Teams-Channel/README.md b/samples/Send-Inline-Image-In-Teams-Channel/README.md new file mode 100644 index 00000000..1ab2dd44 --- /dev/null +++ b/samples/Send-Inline-Image-In-Teams-Channel/README.md @@ -0,0 +1,98 @@ +# Send Inline Image In Teams Channel + +## Summary + +This sample gets the image from SharePoint document library and post it on *Microsoft Teams* channel using **Power Automate**. The flow utilizes standard **Send Microsoft graph request** action to overcome the payload size limit of 28 KB. + +![Flow overview](/samples/Send-Inline-Image-In-Teams-Channel/assets/flow-overview.png "Flow overview") + + +## Applies to + +* [Power Automate](https://docs.microsoft.com/power-automate/) +* [Microsoft Teams](https://learn.microsoft.com/en-us/microsoftteams/) + +## Compatibility + +![Premium License](https://img.shields.io/badge/Premium%20License-Not%20Required-green.svg "Premium license not required") +![On-Premises Connectors](https://img.shields.io/badge/On--Premises%20Connectors-No-green.svg "Does not use on-premise connectors") +![Custom Connectors](https://img.shields.io/badge/Custom%20Connectors-Not%20Required-green.svg "Does not use custom connectors") + + +## Contributors + +* [Manish Solanki](https://github.com/Solanki-Manish) + + +## Version history + +Version|Date|Comments +-------|----|-------- +1.0|May 21, 2024|Initial release + + +## Features + +This sample illustrates the following concepts: + +* Post embed image in Teams Channel message +* Overcome the payload size limit (28 KB) +* Send a Microsoft Graph HTTP request using standard action +* Expression + + +## Prerequisites + +* This Flow requires an image to be present in SharePoint document library (inside site asset). +* A Microsoft Teams with a channel where image needs to be shared via message. + +### Connection References +The solution includes two connection references. +* SharePoint Connection +* Microsoft Teams Connection + +## Minimal Path to Awesome + +### Import Solution + +* [Download](./solution/send-inline-image-in-teams-channel.zip) the `.zip` from the `solution` folder +* [Import](https://learn.microsoft.com/en-us/power-apps/maker/data-platform/import-update-export-solutions) the `.zip` file using **Solutions** > **Import Solution**. + +### Configure Flow + +1. Once the solution is imported, edit it +1. Select **Get file content** action and replace the **Site Address** and the **File Identifier** to point to your SharePoint site and image file. + ![Configure Get file content action](./assets/config1.png) +1. Select **Get team** action and choose a MS team from the drop down. + ![Configure Get team action](./assets/config2.png) +1. Save and test the flow. + +### Using the source code + +You can also use the [Power Apps CLI](https://docs.microsoft.com/powerapps/developer/data-platform/powerapps-cli) to pack the source code by following these steps: + +* Clone the repository to a local drive +* Pack the source files back into a solution `.zip` file: + + ```bash + pac solution pack --zipfile pathtodestinationfile --folder pathtosourcefolder --processCanvasApps + ``` + + Making sure to replace `pathtosourcefolder` to point to the path to this sample's `sourcecode` folder, and `pathtodestinationfile` to point to the path of this solution's `.zip` file (located under the `solution` folder) +* Within **Power Apps Studio**, import the solution `.zip` file using **Solutions** > **Import Solution** and select the `.zip` file you just packed. + +## Help + +We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues. + +If you encounter any issues while using this sample, you can [create a new issue](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=Send-Inline-Image-In-Teams-Channel&authors=@Solanki-Manish&title=Send-Inline-Image-In-Teams-Channel). + +For questions regarding this sample, [create a new question](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=Send-Inline-Image-In-Teams-Channel&authors=@Solanki-Manish&title=Send-Inline-Image-In-Teams-Channel). + +Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerapps-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=Send-Inline-Image-In-Teams-Channel&authors=@Solanki-Manish&title=Send-Inline-Image-In-Teams-Channel). + +## Disclaimer + +**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.** + + \ No newline at end of file diff --git a/samples/Send-Inline-Image-In-Teams-Channel/assets/config1.png b/samples/Send-Inline-Image-In-Teams-Channel/assets/config1.png new file mode 100644 index 00000000..10ec0220 Binary files /dev/null and b/samples/Send-Inline-Image-In-Teams-Channel/assets/config1.png differ diff --git a/samples/Send-Inline-Image-In-Teams-Channel/assets/config2.png b/samples/Send-Inline-Image-In-Teams-Channel/assets/config2.png new file mode 100644 index 00000000..653255ab Binary files /dev/null and b/samples/Send-Inline-Image-In-Teams-Channel/assets/config2.png differ diff --git a/samples/Send-Inline-Image-In-Teams-Channel/assets/flow-overview.png b/samples/Send-Inline-Image-In-Teams-Channel/assets/flow-overview.png new file mode 100644 index 00000000..b8f997c3 Binary files /dev/null and b/samples/Send-Inline-Image-In-Teams-Channel/assets/flow-overview.png differ diff --git a/samples/Send-Inline-Image-In-Teams-Channel/assets/sample.json b/samples/Send-Inline-Image-In-Teams-Channel/assets/sample.json new file mode 100644 index 00000000..1787184e --- /dev/null +++ b/samples/Send-Inline-Image-In-Teams-Channel/assets/sample.json @@ -0,0 +1,65 @@ +[ + { + "name": "pnp-powerplatform-samples-Send-Inline-Image-In-Teams-Channel", + "source": "pnp", + "title": "Send Inline Image In Teams Channel", + "shortDescription": "This sample gets the image from SharePoint document library and post it on Microsoft Teams channel using Power Automate.", + "url": "https://github.com/pnp/powerplatform-samples/tree/main/samples/Send-Inline-Image-In-Teams-Channel", + "downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/powerplatform-samples/tree/main/samples/Send-Inline-Image-In-Teams-Channel", + "longDescription": [ + "This sample gets the image from SharePoint document library and post it on Microsoft Teams channel using Power Automate." + ], + "creationDateTime": "2024-05-21", + "updateDateTime": "2024-05-21", + "products": [ + "Power Automate" + ], + "tags": [ + "Image", + "Teams" + ], + "categories": [ + "CLOUD-FLOW" + ], + "metadata": [ + { + "key": "POWERAPPS-EXPERIMENTAL", + "value": "No" + }, + { + "key": "POWERAPPS-PREMIUM", + "value": "No" + }, + { + "key": "POWERAPPS-ONPREM", + "value": "No" + }, + { + "key": "POWERAPPS-CUSTOMCONNECTOR", + "value": "No" + } + ], + "thumbnails": [ + { + "type": "image", + "order": 100, + "url": "https://github.com/pnp/powerplatform-samples/raw/main/samples/Send-Inline-Image-In-Teams-Channel/assets/flow-overview.png", + "alt": "App preview" + } + ], + "authors": [ + { + "gitHubAccount": "Solanki-Manish", + "pictureUrl": "https://github.com/Solanki-Manish.png", + "name": "Manish Solanki" + } + ], + "references": [ + { + "name": "Microsoft Power Platform documentation", + "description": "Discover how to make the most of Microsoft Power Platform products with online training courses, docs, and videos covering product capabilities and how-to guides.", + "url": "https://learn.microsoft.com/power-platform/" + } + ] + } +] \ No newline at end of file diff --git a/samples/Send-Inline-Image-In-Teams-Channel/solution/Send-Inline-Image-In-Teams-Channel.zip b/samples/Send-Inline-Image-In-Teams-Channel/solution/Send-Inline-Image-In-Teams-Channel.zip new file mode 100644 index 00000000..7d17c72e Binary files /dev/null and b/samples/Send-Inline-Image-In-Teams-Channel/solution/Send-Inline-Image-In-Teams-Channel.zip differ diff --git a/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Other/Customizations.xml b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Other/Customizations.xml new file mode 100644 index 00000000..d1bbf6d8 --- /dev/null +++ b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Other/Customizations.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + SharePoint SendInlineImageInTeamChannelMessage-383e5 + /providers/Microsoft.PowerApps/apis/shared_sharepointonline + 1 + 0 + 1 + + + Microsoft Teams SendInlineImageInTeamChannelMessage-0aed3 + /providers/Microsoft.PowerApps/apis/shared_teams + 1 + 0 + 1 + + + + 1033 + + \ No newline at end of file diff --git a/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Other/Solution.xml b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Other/Solution.xml new file mode 100644 index 00000000..a9c92f46 --- /dev/null +++ b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Other/Solution.xml @@ -0,0 +1,85 @@ + + + + SendInlineImageInTeamChannelMessage + + + + + 1.0.0.0 + 2 + + Cr21a13 + + + + + + + crfc6 + 12078 + +
+ 1 + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ 2 + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + +
+
\ No newline at end of file diff --git a/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Workflows/SendInlineImagetoMSTeams-19B43050-F023-EF11-840A-002248D5E947.json b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Workflows/SendInlineImagetoMSTeams-19B43050-F023-EF11-840A-002248D5E947.json new file mode 100644 index 00000000..080843c8 --- /dev/null +++ b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Workflows/SendInlineImagetoMSTeams-19B43050-F023-EF11-840A-002248D5E947.json @@ -0,0 +1,175 @@ +{ + "properties": { + "connectionReferences": { + "shared_sharepointonline": { + "runtimeSource": "embedded", + "connection": { + "connectionReferenceLogicalName": "crfc6_sharedsharepointonline_383e5" + }, + "api": { + "name": "shared_sharepointonline" + } + }, + "shared_teams_2": { + "runtimeSource": "embedded", + "connection": { + "connectionReferenceLogicalName": "crfc6_sharedteams_0aed3" + }, + "api": { + "name": "shared_teams" + } + } + }, + "definition": { + "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "$connections": { + "defaultValue": {}, + "type": "Object" + }, + "$authentication": { + "defaultValue": {}, + "type": "SecureObject" + } + }, + "triggers": { + "manual": { + "metadata": { + "operationMetadataId": "955fbd0e-2cdf-400d-aa45-29096271ec0b" + }, + "type": "Request", + "kind": "Button", + "inputs": { + "schema": { + "type": "object", + "properties": {}, + "required": [] + } + } + } + }, + "actions": { + "Get_file_content": { + "runAfter": {}, + "metadata": { + "%252fSiteAssets%252fgood_morning_PNG47.png": "/SiteAssets/good_morning_PNG47.png", + "operationMetadataId": "523d3560-92f9-4893-95ae-66256249fd8c" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_sharepointonline", + "operationId": "GetFileContent", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" + }, + "parameters": { + "dataset": "https://pslgrp.sharepoint.com/sites/TMP", + "id": "%252fSiteAssets%252fgood_morning_PNG47.png", + "inferContentType": true + }, + "authentication": { + "type": "Raw", + "value": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']" + } + } + }, + "Get_a_team": { + "runAfter": { + "Get_file_content": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "ab5eeee1-aae2-479f-abd9-6be01d1b9344" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_teams_2", + "operationId": "GetTeam", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_teams" + }, + "parameters": { + "teamId": "4bf06683-bcc7-43b9-82f8-1c7df2d76177" + }, + "authentication": { + "type": "Raw", + "value": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']" + } + } + }, + "List_channels": { + "runAfter": { + "Get_a_team": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "47ef8e0c-3561-4f70-8b15-afca70057dec" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_teams_2", + "operationId": "GetChannelsForGroup", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_teams" + }, + "parameters": { + "groupId": "@body('Get_a_team')?['id']" + }, + "authentication": { + "type": "Raw", + "value": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']" + } + } + }, + "Filter_array": { + "runAfter": { + "List_channels": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "907f6247-ac40-4360-a6af-98809e679200" + }, + "type": "Query", + "inputs": { + "from": "@outputs('List_channels')?['body/value']", + "where": "@equals(item()?['displayName'], 'General')" + } + }, + "Send_a_Microsoft_Graph_HTTP_request": { + "runAfter": { + "Filter_array": [ + "Succeeded" + ] + }, + "metadata": { + "operationMetadataId": "0aefdaed-a27f-461a-90e2-76962753bd35" + }, + "type": "OpenApiConnection", + "inputs": { + "host": { + "connectionName": "shared_teams_2", + "operationId": "HttpRequest", + "apiId": "/providers/Microsoft.PowerApps/apis/shared_teams" + }, + "parameters": { + "Uri": "https://graph.microsoft.com/v1.0/teams/@{outputs('Get_a_team')?['body/id']}/channels/@{first(body('Filter_array'))?['id']}/messages", + "Method": "POST", + "Body": "{\n\t\"body\": {\n \"contentType\": \"html\",\n \"content\": \"
\\n
\\n\\n
Good Morning!
\\n
\"\n },\n \"hostedContents\":[\n {\n \"@microsoft.graph.temporaryId\": \"1\",\n \"contentBytes\": \"@{body('Get_file_content')?['$content']}\",\n \"contentType\": \"@{body('Get_file_content')?['$content-type']}\"\n }\n ]\n}\n", + "ContentType": "application/json" + }, + "authentication": { + "type": "Raw", + "value": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']" + } + } + } + } + }, + "templateName": "" + }, + "schemaVersion": "1.0.0.0" +} \ No newline at end of file diff --git a/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Workflows/SendInlineImagetoMSTeams-19B43050-F023-EF11-840A-002248D5E947.json.data.xml b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Workflows/SendInlineImagetoMSTeams-19B43050-F023-EF11-840A-002248D5E947.json.data.xml new file mode 100644 index 00000000..26dc103c --- /dev/null +++ b/samples/Send-Inline-Image-In-Teams-Channel/sourcecode/Workflows/SendInlineImagetoMSTeams-19B43050-F023-EF11-840A-002248D5E947.json.data.xml @@ -0,0 +1,26 @@ + + + /Workflows/SendInlineImagetoMSTeams-19B43050-F023-EF11-840A-002248D5E947.json + 1 + 0 + 5 + 0 + 4 + 0 + 0 + 0 + 0 + 0 + 1 + 2 + 1 + 1 + 1.0.0.0 + 1 + 0 + 1 + none + + + + \ No newline at end of file