I am using OpenFlow Cloud (app.openiap.io
) and I have WorkItems in it. Now, using Node‑RED Cloud, I want to access WorkItems by name and extract the required requestId
so I can send the result back to the client.
Can you explain a little more what you are trying to do? Work items are not meant to be fetched by properties in the payload or name, but to be used as a queue where you get a “random” item that needs to be processed. If the reason you want to do this is that you are processing the items in a different place, you can “chain” work item queues by setting a success queue.
There are two reasons for this: the collection with items can become extremely big, so index optimization is harder, and we want to avoid using it for other things. Secondly, in almost all cases, there are other ways to do this.
OpenCore itself has a database, so if you need to store and look up data, you can always store data inside it (like in the entities collection).
Hi Allen,
Let me explain with an example:
I created a flow where a client sends me some data (a file and a prompt) through an API built in Node‑RED. Using automation, I connect it with an OpenRPA bot to store the file locally, then I use it with ChatGPT to generate a response. That response is then pushed into a queue in JSON format.
For every request made by the client, I assign a requestId (so each question has its own unique ID).
Now, I want to fetch the specific response from the queue when the client calls a GET API using that requestId. Essentially, I want to access a particular WorkItem from the queue that matches the requestId and then return its payload to the client.
I’ve already set the WorkItem names as the requestIds. My question is:
How can I access the queue to find that particular WorkItem by requestId and fetch its payload? hope now could be able to explain
In nodered you can use the get
node, to fetch data from the database.
You can the create a query on the msg object ( notice i select “msg” under query and change “top” to 1 )
Next, use http node with /response/:id
and in a function node, get the id, store it as the right type and create a query based on the id
// if you saved id as a number
// let id = parseInt(msg.req.params.id)
// if you saved id as a string
let id = msg.req.params.id.toString()
msg.query = {"payload.requestId" : id}
return msg;
But like i said, i highly recommend you store that data in a different collection (like entities), and fetch it from there. You can insert/update/query/delete data from both OpenRPA and NodeRED
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.