Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure Content Moderator API for text screening in Power Automate #51

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
76 changes: 76 additions & 0 deletions samples/azure-content-moderation-text/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Azure HTTP Key Vault

## Summary

Demonstrates how Content Moderation Azure API can be used with the power automate

![picture of the flow](assets/flow.png)

## Applies to

* [Microsoft Power Automate](https://docs.microsoft.com/en-us/power-automate/getting-started)
* [Azure Logic Apps](https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-overview)

## Compatibility

![Premium License](https://img.shields.io/badge/Premium%20License-Required-yellow.svg "Premium license 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")

## Authors

Solution|Author(s)
--------|---------
azure-content-moderation-text | [Divya Akula](https://github.com/divya-akula)

## Version history

Version|Date|Comments
-------|----|--------
1.0|Aug 19, 2023|Initial release

## Features
Azure Content moderation helps to streamline or moderate the data which includes text , image and video . These services can be used by any application by the API endpoints provided by azure.

The flow demonstrates how to moderate text in two easy steos

Prerequisites:
This app uses Content Moderation resource and Http Premium Connector.
1. User has to navigate to [Azure Portal](https://portal.azure.com)
2. Create new resource for Content Moderation ,

![picture of the flow](assets/AzureContentModerationResourceProvision.png)

3. Once the resource is provisioned,navigate to the **Resource** > **Content moderation* > **Keys and Endpoint**
![picture of the flow](assets/AzureKeysAndEndPoint.png)

4. Using the Keys and endpoint invoke the flow with the appropriate parametess

![picture of the flow](assets/PowerplatformRunOutput.png)

## Minimal Path to Awesome

* [Download](solution/ModerateText.zip) the `.zip` from the `solution` folder
* [Import](https://flow.microsoft.com/en-us/blog/import-export-bap-packages/) the `.zip` file using **My Flows** > **Import** > **Upload** within Microsoft Flow.

## 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.**

## Help

We do not support samples, but we 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, [create a new issue](https://github.com/pnp/powerautomate-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=bug-report.yml&sample=always-reply-to-request&authors=@remyblok&title=always-reply-to-request%20-%20).

For questions regarding this sample, [create a new question](https://github.com/pnp/powerautomate-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=question.yml&sample=always-reply-to-request&authors=@remyblok&title=always-reply-to-request%20-%20).

Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/powerautomate-samples/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected&template=suggestion.yml&sample=always-reply-to-request&authors=@remyblok&title=always-reply-to-request%20-%20).

## For more information

- [Create your first flow](https://docs.microsoft.com/en-us/power-automate/getting-started#create-your-first-flow)
- [Microsoft Power Automate documentation](https://docs.microsoft.com/en-us/power-automate/)


<img src="https://telemetry.sharepointpnp.com/powerautomate-samples/samples/exception-handing-in-do-until-loop" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
73 changes: 73 additions & 0 deletions samples/azure-content-moderation-text/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
[
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/pnp/samples/v1.0/metadata-schema.json",
"name": "pnp-powerautomate-samples-azure-http-key-vault",
"version": "1.0.0.0",
"source": "pnp",
"creationDateTime": "2022-09-16",
"updateDateTime": "2021-09-16",
"title": "Leveraging Graph API to get password from Azure Key Vault",
"shortDescription": "A sample for geeting the keyvault details using graph api",
"longDescription": [
"The sample provides details on can you leverage the graph api to connect to azure platform along with the authentication details"
],
"url": "https://github.com/pnp/powerautomate-samples/tree/main/samples/azure-http-key-vault",
"products": [
"Power Automate",
"Azure"
],
"tags": [
"PATTERNS",
"EXCEPTION-HANDLING"
],
"categories": [
"POWERAUTOMATE"
],
"metadata": [
{
"key": "POWERAUTOMATE-PREMIUM",
"value": "yes"
},
{
"key": "POWERAUTOMATE-ONPREM",
"value": "No"
},
{
"key": "POWERAUTOMATE-CUSTOMCONNECTOR",
"value": "No"
}
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://github.com/pnp/powerautomate-samples/blob/main/samples/azure-http-key-vault/assets/flow.png?raw=true",
"alt": "Preview of the solution"
}
],
"authors": [
{
"gitHubAccount": "divya-akula",
"name": "Divya Akula",
"pictureUrl": "https://avatars.githubusercontent.com/u/9211327?v=4"
}
],
"references": [
{
"name": "Create your first flow",
"description": "Anyone from a basic business user to an IT professional can create automated processes using Power Automate's no-code/low-code platform.",
"url": "https://docs.microsoft.com/en-us/power-automate/getting-started#create-your-first-flow"
},
{
"name": "Microsoft Power Automate documentation",
"description": "Power Automate is a service that helps you create automated workflows between your favorite apps and services to synchronize files, get notifications, collect data, and more.",
"url": "https://docs.microsoft.com/en-us/power-automate/"
},
{
"name": "Application Registration in Azure",
"description": "Application registration would be needed whenever we are trying to access any of the graph APIs",
"url": "https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis"
}
]
}
]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"c78ae92d-3b44-43d9-b31b-bc2213443e40","id":"/providers/Microsoft.Flow/flows/c78ae92d-3b44-43d9-b31b-bc2213443e40","type":"Microsoft.Flow/flows","properties":{"apiId":"/providers/Microsoft.PowerApps/apis/shared_logicflows","displayName":"ModerateText","definition":{"metadata":{"workflowEntityId":null,"processAdvisorMetadata":null,"flowChargedByPaygo":null,"flowclientsuspensionreason":"None","flowclientsuspensiontime":null,"flowclientsuspensionreasondetails":null,"creator":{"id":"e15cde1d-edef-4114-bdf4-bd62689f2061","type":"User","tenantId":"c09030dd-81e0-44af-a342-68c9358c43dd"},"provisioningMethod":"FromDefinition","failureAlertSubscription":true,"clientLastModifiedTime":"2023-08-17T00:29:52.2641042Z"},"$schema":"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#","contentVersion":"1.0.0.0","parameters":{"$authentication":{"defaultValue":{},"type":"SecureObject"}},"triggers":{"manual":{"metadata":{"operationMetadataId":"0e84ae0f-bba8-4fd6-b9d2-3606d24fafe4"},"type":"Request","kind":"PowerApp","inputs":{"schema":{"type":"object","properties":{"Initializevariable2_Value":{"type":"any"},"IVPII_Value":{"type":"boolean","description":"Enter initial value","x-ms-powerflows-param-ispartial":false},"IVClassify_Value":{"type":"boolean","description":"Enter initial value","x-ms-powerflows-param-ispartial":false},"IVBody_Value":{"type":"string","description":"Enter initial value","x-ms-powerflows-param-ispartial":false},"IVAutoCorrect_Value":{"type":"boolean","description":"Enter initial value","x-ms-powerflows-param-ispartial":false}},"required":["Initializevariable2_Value","IVPII_Value","IVClassify_Value","IVBody_Value","IVAutoCorrect_Value"]}}}},"actions":{"HTTP":{"runAfter":{"IVBody":["Succeeded"]},"metadata":{"operationMetadataId":"7b4b0981-f338-4ec6-aace-c3742a1ea571"},"type":"Http","inputs":{"method":"POST","uri":"@variables('RestAPI')","headers":{"Ocp-Apim-Subscription-Key":"de82e38a3dc04cd088c837c7ac112640"},"body":"@variables('Content')"}},"Initialize_variable":{"runAfter":{"IVClassify":["Succeeded"]},"metadata":{"operationMetadataId":"73bcda67-96b4-4168-a37a-ecaa8221d78e"},"type":"InitializeVariable","inputs":{"variables":[{"name":"RestAPI","type":"string","value":"https://modera.cognitiveservices.azure.com/contentmoderator/moderate/v1.0/ProcessText/Screen?autocorrect=@{variables('AutoCorrect')}&PII=@{variables('PII')}&classify= @{variables('Classify')}"}]}},"IVAutoCorrect":{"runAfter":{},"metadata":{"operationMetadataId":"3422db53-8ffa-432c-a5d0-d64cb13ad7f0"},"type":"InitializeVariable","inputs":{"variables":[{"name":"AutoCorrect","type":"boolean","value":"@triggerBody()['IVAutoCorrect_Value']"}]}},"IVPII":{"runAfter":{"IVAutoCorrect":["Succeeded"]},"metadata":{"operationMetadataId":"b6acbf3f-aaf1-41d2-bc3d-cde0ac9cef53"},"type":"InitializeVariable","inputs":{"variables":[{"name":"PII","type":"boolean","value":"@triggerBody()['IVPII_Value']"}]}},"IVClassify":{"runAfter":{"IVPII":["Succeeded"]},"metadata":{"operationMetadataId":"2b516d84-8ae1-44f3-a404-3ce902dddeab"},"type":"InitializeVariable","inputs":{"variables":[{"name":"Classify","type":"boolean","value":"@triggerBody()['IVClassify_Value']"}]}},"IVBody":{"runAfter":{"Initialize_variable":["Succeeded"]},"metadata":{"operationMetadataId":"3422db53-8ffa-432c-a5d0-d64cb13ad7f0"},"type":"InitializeVariable","inputs":{"variables":[{"name":"Content","type":"string","value":"@{triggerBody()['IVBody_Value']}"}]}},"Respond_to_a_PowerApp_or_flow":{"runAfter":{"HTTP":["Succeeded"]},"metadata":{"operationMetadataId":"52fb1c2f-aef2-40b1-81b8-cad640a9cb05"},"type":"Response","kind":"PowerApp","inputs":{"statusCode":200,"body":{"outputs":"@{body('HTTP')}"},"schema":{"type":"object","properties":{"outputs":{"title":"Outputs","x-ms-dynamically-added":true,"type":"string"}}}}}}},"connectionReferences":{},"flowFailureAlertSubscribed":false,"isManaged":false}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"packageSchemaVersion":"1.0","flowAssets":{"assetPaths":["2ef70e39-21bb-4d7f-8511-06e32dc375bd"]}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"schema":"1.0","details":{"displayName":"TextModeration","description":"","createdTime":"2023-08-19T14:38:48.0701251Z","packageTelemetryId":"e20caa14-fb85-4e26-b6fe-b334c973dbdd","creator":"N/A","sourceEnvironment":""},"resources":{"2ef70e39-21bb-4d7f-8511-06e32dc375bd":{"type":"Microsoft.Flow/flows","suggestedCreationType":"Update","creationType":"Existing, New, Update","details":{"displayName":"ModerateText"},"configurableBy":"User","hierarchy":"Root","dependsOn":[]}}}