Hello everyone,
I'm currently working on extracting specific fields from a blueprint API call. This API call can be accessed via the following URL: https://eu1.callin.io/api/v2/scenarios/SCENARIO_ID/blueprint . When invoked, it returns a substantial amount of data from the scenario blueprint, which is useful for export or import purposes.
My goal, however, is to isolate only the essential items from the JSON response and then send this curated data to either OpenAI or Anthropic, depending on the token count. The intention is to generate documentation for the scenario or provide an explanation of its functionality.
I'm facing challenges with data mapping. Within the blueprint.flow
section, there's an array of modules, and each module contains several collections. The specific information I need is located within the mapper
collection, and I want to exclude metadata and parameters. Given that blueprints can vary significantly, it's not practical to map each value individually or to solely focus on the mapper
collection (please see the attached screenshot).
Therefore, I'm looking for advice on how to transform the data into my own JSON format, enabling me to exclude all the 'unnecessary' fields. This is crucial because the extensive data either exhausts the available tokens or overwhelms the AI due to its complexity.
Any assistance would be greatly appreciated.
Hi,
I'm not entirely sure about your specific use case, but working with JSON data that has an undefined structure can indeed be challenging, and I'm not certain if it's directly achievable.
However, if you know the structure of the JSON you'll receive in your module beforehand, here's a potential approach:
-
From the Blueprint response, you can fetch all mappers associated with the
__http:ActionSendData
module. To do this, you can utilize themap
function directly. Then, within the filter, you can specifycontentType
asapplication/json
. While it's possible to achieve this with anothermap
function, it might become quite intricate.
{{map(1.data.flow; “mapper”; “module”; “http:ActionSendData”)}}
In this snippet,
data.flow
would refer to your blueprint's flow. -
Insert a filter step to verify that the
contentType
of the iterator's result isapplication/json
. - Subsequently, add a
Parse JSON
module to process the data body.
Your workflow should resemble something like this:
Thanks for the explanation, but I believe that's precisely the problem, as you noted:
Working with JSON whose data structure is not predefined can be tricky, and I'm not sure if that is achievable. However, if you know beforehand the structure of the JSON you will have in your module, then what you can do is:
I don't know the structure of the JSON because I'd like to do this with all my scenarios, and the possible JSON structures are as numerous as callin.io has integrations.