Creating API Token/Key so I can start a workflow remotely by API call

OpenRPA version: 1.4.57
Using app.openiap.io
I am trying to start a workflow remotely using an API call. I am trying to avoid the additional complexity of setting up NodeRed. I have found various sources but i keep hitting upon not knowing how to generate an API key and then what URL to actually call. This is the Powershell script i am looking to use. When i ask the chat feature it says the workflow is missing to create a key and the seetings page it refers me to is not there on the OpenCore site.

# 🔐 Your token
$token = "TOKENGOES HERE"

# ✅ Correct backend API endpoint
$uri = "https://api.openiap.io/api/v1/invokeopenrpa"

# 📨 Request body
$body = @{
    workflow = "WORKFLOW ID GOES HERE"
    rpc = $true
} | ConvertTo-Json -Depth 3

# 📦 Headers
$headers = @{
    Authorization = "Bearer $token"
    "Content-Type" = "application/json"
}

# 🚀 Make the call
$response = Invoke-RestMethod -Uri $uri -Method POST -Headers $headers -Body $body

# 🖨️ Show result
$response | ConvertTo-Json -Depth 10

Hey Alex,
Gotta love ChatGPT and hallucinations :slight_smile:
There is no “dedicated” domain for API calls.

Using REST

You can create a REST client in any of the 11 supported languages and run as an agent. But if you don’t want to run NodeRed, I’m assuming you don’t want to run an agent either. So, that leaves:

Using Client Library

Hopefully, you are working within one of these programming languages: OpenIAP SDK Documentation. Depending on the language, install the client library for your code base. Make sure you are at least using version 0.0.33. Then, you can trigger a robot using something like:

C/C++

struct InvokeOpenRPARequestWrapper req;
req.robotid = "5ce94386320b9ce0bc2c3d07";
req.workflowid = "5e0b52194f910e30ce9e3e49";
req.payload = "{\"test\":\"test\"}";
req.rpc = true;
struct InvokeOpenRPAResponseWrapper *resp = invoke_openrpa(client, &req, 10);
if (resp == NULL) {
    printf("Error: invoke_openrpa returned NULL.\n");
} else {
    if (!resp->success) {
        printf("Invoke OpenRPA failed: %s\n", resp->error);
    } else {
        printf("Invoke OpenRPA result: %s\n", resp->result);
    }
    free_invoke_openrpa_response(resp);
}            

Or if you are more into Python:

try:
    result = client.invoke_openrpa(
        "5ce94386320b9ce0bc2c3d07",
        "5e0b52194f910e30ce9e3e49",
        {"test": "test"},
        timeout=10
    )
    print("Invoke OpenRPA result:", result)
except Exception as e:
    print(f"Invoke OpenRPA failed: {e}")

Or .NET:

try {
  var rparesult = client.InvokeOpenRPA("5ce94386320b9ce0bc2c3d07",
      "5e0b52194f910e30ce9e3e49", "{\"test\":\"test\"}", true, 10);
  client.info("rpa result " + rparesult);
} catch (System.Exception ex) {
  client.error("Client connection error: " + ex.Message);
}

I think you get the idea …

This May Break in the Future, So Not Recommended

I think what ChatGPT was referring to is the OpenAPI endpoint in OpenCore. There is an /api/v1/runopenrpaworkflow/{robotname}, but this is not really “officially” supported. It was used as part of adding functions to ChatGPT GPT’s using OpenIAP OpenAPI Documentation (OpenIAP OpenAPI Documentation).

See my post here Using OpenAI GPTs with OpenFlow for my “call out” to the community to see if that is something people want.

Forgot to mention, you manage tokens and connection strings using the openiap extension in vs.code or cursor … see docs or video here

Oh no thats so funny. I feel slightly scammed :slight_smile:
So it sounds like I may as well set some time aside to learn NodeRed. I am trying to get a smart telegram bot running that can respond and perform actions. I was toying with the idea of building something in Vercel to do the responding and then when it had all the info for the workflow calling that. But i am not a proper coder and am trying to find the simplest approach. I imagine NodeRed would give all the capability i need.
Thanks again

There is a “JS API” specifically for browser/frontend frameworks, so you can call the robot directly from whatever app you host in Vercel

npm -D i openiap/jsapi#esm

Documented here

It’s primarily made for websites that use OpenCore as an identity provider, so when you make requests, you do it as the user that is signed in. But if you make sure to only do it server-side (if you’re working in Next, Nuxt, SvelteKit, etc.) and store the token there, I guess you can skip that part and always do the request with some predefined user token.

I noticed you like powershell, so i made a powershell module and published to PsGallery

PS /mnt/data/vscode/config/workspace/code> install-module openiap                                       

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository 
cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
PS /mnt/data/vscode/config/workspace/code> Invoke-OpenRPA -RobotId "5ce94386320b9ce0bc2c3d07" -WorkflowId "5e0b52194f910e30ce9e3e49"

test
----
DESKTOP-RI0ACCQ\allan

PS /mnt/data/vscode/config/workspace/code> $result = Invoke-Query -Collection "entities" -Top 10 -Projection '{"name":1}'    
PS /mnt/data/vscode/config/workspace/code> $result | Format-Table -AutoSize                                                  

_id                      name
---                      ----
663292dc6a1f9ab8e6d339ee find me 22
6652d5eeaa2d768dbb140e29 new item
666c0141e7ccba0e85b8a0d9 Hi Allanwefewfwefewefewfewfew
66b33f52c8d208f0d3d3861b allan
66b7205dc8d208f0d3d393a6 test from rust
66b7205dc8d208f0d3d393a5 test many from rust 1
66b7205ec8d208f0d3d393a7 test many from rust 2
66b720b3c8d208f0d3d393b8 test many from rust 2
66b720b3c8d208f0d3d393b5 test many from rust 1
66b720b6c8d208f0d3d393b9 test from rust

PS /mnt/data/vscode/config/workspace/code>