Use Case - Running your Power Automate Flows From Anywhere

In this use case, we describe how to securely run Power Automate flows from anywhere. This is useful if you have your own internal tool on premise and you want to integrate it with Nimbus. Or if your organization is large and your team does not have the license for Power Automate but you would like to use Nimbus' Power Automate Connector to create external tasks or outbound calls.

 

We assume that we have a custom on premise ticketing system which communicates over REST APIs to other systems. We want to route the tickets from that system to Nimbus. Let's do it!

Create the External Task Flow

  1. To start your flow, add the “When a HTTP request is received” trigger in order to add security to the flow. 
  2. As we want to trigger this flow from within our custom ticketing system, we define the fields we want to post to the flow in the body schema. You can generate it using your custom payload. We used this:
{  
 "serviceupn": "This will be the Nimbus service upn@tenant.com",  
 "ticketId": "3",  
 "ticketTitle": "My ticket title",  
 "ticketStatus": "Open",  
 "ticketDescription": "My ticket description",  
 "ticketLink": "A deeplink to our on prem solution",  
 "customerDisplayname": "Client Name",  
 "customerEmail": "client@hello.com",  
 "customerCompany": "Hello Inc",  
 "customerPhone": "+44999999999"  
}
  1. Add “Add a new external task” from the Nimbus connector to the flow. Add the values from the triggers body to the external task fields.

     
  2. Save the flow and copy the generated HTTP POST URL for later steps.

Add an Application Registration to Your Tenant

  1. Create an app registration in your tenant for the sole purpose of running the PA flows.
  2. Add the following application permissions:
  3. Create a client secret and copy the generated secret, client id and tenant id for later steps. 

Run the Power Automate Flows 

  1. With your favorite REST client or in JavaScript, authenticate on the Azure Cloud with your new app registration using the URL https://login.microsoftonline.com/${your-tenant-id}/oauth2/v2.0/token and the previously saved values.
    Here is an example in JavaScript:
const tenantId = "your-tenant-id"
const clientId = 'your-client-id';
const clientSecret = 'your-client-secret';
const scope = `https://service.flow.microsoft.com//.default`;
 
export async function authenticate(){
      const tokenResponse = await fetch(`https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`, {
      method: 'POST',
      body: new URLSearchParams({
        grant_type: 'client_credentials',
        client_id: clientId,
        client_secret: clientSecret,
        scope: scope,
      }),
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',    
 });
	const tokenData = await tokenResponse.json();
    return tokenData.access_token;
}

 

  1. With the access Bearer token you can now call your Power Automate flow using the HTTP POST URL you saved previously:

 

const triggerUrl="https://xxxxxx.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxx/triggers/manual/paths/invoke?api-version=2016-06-01";
const payload = {
		serviceupn: "This will be the Nimbus service upn@tenant.com",  
 		ticketId: "3",  
 		ticketTitle: "My ticket title",  
 		ticketStatus: "Open",  
 		ticketDescription: "My ticket description",  
 		ticketLink: "A deeplink to our on prem solution",  
 		customerDisplayname: "Client Name",  
 		customerEmail: "client@hello.com",  
 		customerCompany: "Hello Inc",  
 		customerPhone: "+44999999999"
 };
 
 const response = await fetch(
      `${triggerUrl}`,
      {
        method: 'POST',
        headers: {
          Authorization: `Bearer ${accessToken}`,
          'Content-Type': 'application/json'
        },
        body: JSON.stringify(payload),
      }
);

⮑ In Nimbus, you will see the task coming in:

Do More

The same technique can also be used for

  • Creating Nimbus outbound calls.
  • Sending adaptive cards to agents with your system links.
  • Forwarding a message as an email to Nimbus (if the email modality is enabled).
  • Forwarding a message as an external task to Nimbus.
  • Forwarding WhatsApp or SMS messages as an external task to Nimbus.

Table of Contents