Giter Site home page Giter Site logo

mikahanninen / powerautomate-robocorp Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 298 KB

Trigger a Robocorp process from Power Automate flow

License: Apache License 2.0

Python 35.81% RobotFramework 64.19%
robocorp process powerautomate email sharepoint workitem api

powerautomate-robocorp's Introduction

Power Automate triggering a Process in Robocorp Control Room

This example will use Microsoft Power Automate flow to monitor new items on Sharepoint list and on each new item will trigger a Robocorp Control Room process with email.

Triggering process run with NEW state work item

Use flow action "Trigger Process" and fill in the workspace_id, process_id and the following body.

{
  "type": "workItemIds",
  "workItemIds": ["82f28d74-a857-4b13-b87f-42dd2d13039d"]
}

About Sharepoint list item details

This example will read Sharepoint list Item contents from the email body of the received trigger email. This is not the most secure way, because data is included in the email.

Alternative approach would be to send link to Sharepoint Item and Robot would access that via MSGraph API.

Steps

Assumption: You have some Sharepoint list which benefits from this Robot.

  1. Create a Robocorp Robot task which will execute on email trigger
  2. Configure a process in Robocorp Control Room
  3. Configure a flow in the Microsoft Power Automate

Step 1. Create a Robocorp Robot task which will execute on email trigger

The Power Automate sends email body as HTML and it can't be configured to plain text. Due to this restriction we will be sending item from Power Automate within placeholder texts to identify Item in the email body. The Item will be placed between ITEMBODYSTART and ITEMBODYEND texts (this will happen at step 3.)

Robot is using custom library (SharepointLibrary.py) to get the Item from the email and RPA.Robocorp.WorkItems library to read work item variable parsedEmail which is a variable automatically provided by the library when Work Item has been triggered with email. The parsedEmail contains all email fields, but in this example we will using only Body field.

Robot will then output all the key-value pairs of the Sharepoint Item.

Step 2. Configure a process in Robocorp Control Room

Upload Robot to your Robocorp Control Room Workspace. Create new process into Control Room and from Configure Process add a step executing Power Automating task of this Robot. Still in the Configure process switch to Schedules & Triggers and add Trigger the process with email - this will generate unique email address which can be used to trigger this Process with an email. Make a copy of the email address as it is needed when we will in the next step configure Power Automate.

Configure step Configure email trigger

Link. https://cloud.robocorp.com

Step 3. Configure a flow in the Microsoft Power Automate

Create a flow into Microsoft Power Automate. You can start with the blank flow. The flow consists of three steps.

Step 3.1. Sharepoint. "When an item is created". This step requires that we will configure Sharepoint site address and the name of the list.

Step 3.2. Sharepoint. "Get item". This step requires that we will configure Sharepoint site address, the name of the list and the Id of the Item (for the Id we will be using the ID from step 1). The Body returned by "Get Item" is a dictionary containing all fields in the Item.

Step 3.3. Email. "Send an email notification (V3)". This step requires that we will configure To address (put here the Robocorp Process trigger email address from Step 2), Subject can be anything because our Robot is not using that information and in the Body place the Body from step 3.2 "Get Item" between placeholder texts.

Flow steps

Link. https://flow.microsoft.com

Control Room step run result (log.html)

Result in the log.html

(ALTERNATIVE) Robocorp Power Automate custom connector

This method can be used to launch Robocorp Process via API with Power Automate custom connector.

Import attached JSON file as a custom connector into Power Automate.

Add New Custom Connector in Power Automate with option Update From OpenAPI URL and give as URL to RAW Github file URL: https://raw.githubusercontent.com/mikahanninen/powerautomate-robocorp/main/Robocorp-Process-API.swagger.json

Connector contains at the moment two actions:

  • Trigger Process
  • Create Input Work Item
  • Get Work Item
  • List Robot Run Artifacts
  • Get a Robot Artifact

Difference between actions is that process with single workitem expects body content as a dictionary and will launch 1 Process step run in the Robocorp Control Room with the given input work item.

The process with multiple workitems expects body content be given multiple workitems in a list (list of dictionaries), which will trigger multiple Process step runs each with different input work item.

Robocorp-Process-API.swagger.json

Get Robocorp Control Room API key

Create Workspace API Access key

Set name for the permission and add trigger_processes permission.

API key name and permission

On the first launch the Power Automate Connection must be created with the Robocorp Control Room API key. Give Connection some easy to remember name so that you can identify it from your other Power Automate Connections.

Create connection Add connection

API Key must be inserted in the following format:

RC-WSKEY <COPY OF CONTROL ROOM API TOKEN IN HERE>

Notice the SPACE character between RC-WSKEY and the token.

Power Automate step configuration

The selected action needs 3 configuration parameters set.

  1. workspace_id - this can be get from Robocorp Control Room settings
  2. process_id - this can be get from Robocorp Control Room process
  3. body - this is a work item content which for Trigger Process action needs

powerautomate-robocorp's People

Contributors

mikahanninen avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.