Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Answered

how to modify the power automate flow for the below scenario?

(0) ShareShare
ReportReport
Posted on by 392

So basically, I'm trying to create a chat bot, it takes user question as input and send to open AI (through api) and return the response to virtual agent chat box.
This is my existing flow.

Jupyter123_3-1675184511111.pngJupyter123_4-1675184528641.pngJupyter123_5-1675184552314.pngJupyter123_6-1675184574008.pngJupyter123_7-1675184609961.pngJupyter123_8-1675184625753.pngJupyter123_9-1675184642877.png

The whole flow looks like this.

Jupyter123_10-1675184679356.png


But, i want to add something in middle of this flow.

There's something called "OpenAI moderations which will check whether content complies with OpenAI's content policy.
https://platform.openai.com/docs/guides/moderation/overview

This is the api URL https://api.openai.com/v1/moderations 
Json Body:

{
"input": "I want to kill them."
}

Json response:

{
"id": "modr-5MWoLO",
"model": "text-moderation-001",
"results": [
{
"categories": {
"hate": false,
"hate/threatening": true,
"self-harm": false,
"sexual": false,
"sexual/minors": false,
"violence": true,
"violence/graphic": false
},
"category_scores": {
"hate": 0.22714105248451233,
"hate/threatening": 0.4132447838783264,
"self-harm": 0.005232391878962517,
"sexual": 0.01407341007143259,
"sexual/minors": 0.0038522258400917053,
"violence": 0.9223177433013916,
"violence/graphic": 0.036865197122097015
},
"flagged": true
}
]
}
as you can see, the above question has some harmful content and the json response shows true.
So, the flow should be like this.
1) the user types the question
2) sends the question to open ai moderations for checking whether there is some harmful content is there or not.

3) if any of the parameters is true, then it should send the response to user, "please double check your question"

4) if any of the parameters is false, then it should send the response to openAI and receive the response back.
So what would be the modified flow of my power automate?

 

  • Jupyter123 Profile Picture
    392 on at
    Re: how to modify the power automate flow for the below scenario?

    thank you very much @abm .
    i've contacted @abm and he helped me out and clearly explained the steps what to be done.
    cheers. and also thanks to @AlexMCC for your response. your answer was almost close to the expected one.

  • Verified answer
    abm abm Profile Picture
    32,464 Most Valuable Professional on at
    Re: how to modify the power automate flow for the below scenario?

    Hi @Jupyter123 

     

    Thanks for the call. This is what we discussed.

     

    Collect the response and add a parse json step to check flagged is true or false? Based on that decision you can terminate the flow with a response. If all good build rest of the business logic and return the results back to the user. If you want to show the user the 'rules are broken' then use a variable to dynamically store flagged text which is 'Sorry you have broken the rules' or use the same variable to return the ChatGPT results back to user.

     

    Thanks

     

    Thanks

  • AlexMCC Profile Picture
    293 on at
    Re: how to modify the power automate flow for the below scenario?

    Add your API check wherever you want it in the flow.

     

    Use a Condition control to check if the JSON response is true.

     

    In the "false" branch add another Return Values followed by a Terminate control to stop the flow.

     

    Just leave the "true" branch blank.

     

    Your flow should look like this:

    Screenshot 2023-02-02 at 07.06.51.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow