I’m starting with robocorp coding in pure python and I want to do a project that have 2 steps.
In the first step a get some data from web sites and build a json with the information
The second step will consume this json to do more things
The problem is, how do I do to make this json file in a work item to consume in the second bot?
This is my result from first bot, a list of dictionary in a json file:
My question is, how can I read this json and create a queue to another bot consume? Thanks
Hi! Welcome to the community!
Have a look at the producer-consumer robot template that we have made available on VS Code when you create a new project. Or you can find it in our portal, too:
It has the structure made for you for the first step (producer) to create work items that are then processed by the second step (consumer).
Another great example is this robot. The detailed documentation is here.
Hope these help!
All right, I undesrtood a little, but i have one doubt yet.
Running local I chose if I’m using a input work item or a output work-item when I run, but and when the bot run “by himself” how he will know what uses?
In this example, if I want to create an output work item, I should chose the “teste” (input), read my file and create my output work-item. If I want to consume a work-item already created I should chose “run-1” or “run-2” to it. But when I schedule the bot how it works?
That’s automatically handled by the Control Room (the cloud orchestrator).
You’ll see this when creating the process, so you have consecutive steps. First would be your producer, and second your consumer.
Now our cloud automatically passes all the output work items (the ones you create with
Create Output Work Item keyword) from Step 1 as the input work items of Step 2.
Very, very thank you, you saved me rs
One more question about this. Can I create 2 output work items in the same script? Like a queue, in the first step I have a script that obtain 2 kinds of data and I want to create 2 queues to be consumed, one in the step 2 and another in the step 3
You can create as many output Work Items as you want in any Step, but you can’t send them into separate queues, as every newly created output item belongs to a parent which is the lastly retrieved input one.
As a workaround, you can embed the
type itself as a field in the Work Item data and you let your Step (2 or 3) decide based on it if it should process the content or pass it to the next Step with
Create Output Work Item.
But TBH this looks like a bad pattern, as every Step should be capable of processing the items it receieves from the previous one. So why isn’t enough to have just 2 Steps instead of 3 and based on the Work Item type you consume as input, you decide with what robot logic to process it within the same step?
Can you ellaborate more your use-case here?
Meanwhile, please read more on how to work with Work Items given the workaround above through these keywords: