Categories
DeepOpinion Tips and Tricks

Data Structure in DeepOpinion

In Studio, all data passed between nodes is an array of objects. It has the following structure:

[
    {
        // For most data:
        // Wrap each item in another object, with the key 'json'
        "json": {
            // Example data
            "jsonKeyName": "keyValue",
            "anotherJsonKey": {
                "lowerLevelJsonKey": 1
            }
        },
        // For binary data:
        // Wrap each item in another object, with the key 'binary'
        "binary": {
            // Example data
            "binaryKeyName": {
                "data": "....", // Base64 encoded binary data (required)
                "mimeType": "image/png", // Best practice to set if possible (optional)
                "fileExtension": "png", // Best practice to set if possible (optional)
                "fileName": "example.png", // Best practice to set if possible (optional)
            }
        }
    },
    ...
]

How to create 10 new items

const newItems = [];

for (let i=0;i<10;i++) {
  newItems.push({
    json: {
      id: i
    }
  });
}

return newItems;

How to access the items from a specific node

const newItems = [];

for (const [index, item] of items.entries()) {
  let nodeData = $item(index).$node["Claim ID Text Extraction"];
  let json = nodeData.json;

  newItems.push({
    textExtractResult: [...json.body.matches_with_confidences],
  });
}

return newItems;

How to create an input with items and multiple attachments

const newItems = [
  {
    binary: {
      attachment_0: {
        data: "...",
        fileExtension: "pdf",
        fileName: "fileName.pdf",
        fileSize: "20.3 kB",
        fileType: "pdf",
        mimeType: "application/pdf",
      },
    },
    json: {
      attachmentCount: 1,
      "@odata.etag": '.."',
      bccRecipients: [],
      body: {
        content:
          '<html><head>\r\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div dir="ltr">test</div></body></html>',
        contentType: "html",
      },
      bodyPreview: "test",
      categories: [],
      ccRecipients: [],
      changeKey: "...",
      conversationId:
        "...",
      conversationIndex: "...",
      createdDateTime: "2025-06-02T21:37:42Z",
      flag: {
        flagStatus: "notFlagged",
      },
      from: {
        emailAddress: {
          address: "...",
          name: "user1",
        },
      },
      hasAttachments: true,
      id: "...",
      importance: "normal",
      inferenceClassification: "focused",
      internetMessageId:
        "...",
      isDeliveryReceiptRequested: null,
      isDraft: false,
      isRead: false,
      isReadReceiptRequested: false,
      lastModifiedDateTime: "2025-06-04T14:55:14Z",
      parentFolderId:
        "...",
      receivedDateTime: "2025-06-02T21:37:43Z",
      replyTo: [],
      sender: {
        emailAddress: {
          address: "user1@mail.com",
          name: "user1",
        },
      },
      sentDateTime: "2025-06-02T21:37:01Z",
      subject: "test",
      toRecipients: [
        {
          emailAddress: {
            address: "user2@mail.com",
            name: "user2",
          },
        },
      ],
      webLink:
        "https://outlook.live.com/owa/",
    },
    pairedItem: {
      item: 0,
    },
  },

  {
    binary: {
      attachment_0: {
        data: "...",
        fileExtension: "pdf",
        fileName: "fileName.pdf",
        fileSize: "20.3 kB",
        fileType: "pdf",
        mimeType: "application/pdf",
      },
      attachment_1: {
        data: "...",
        fileExtension: "jpg",
        fileName: "fileName.jpg",
        fileSize: "181 kB",
        fileType: "image",
        mimeType: "image/jpeg",
      },
      attachment_2: {
        data: "...",
        fileExtension: "pdf",
        fileName: "fileName.pdf",
        fileSize: "19.7 kB",
        fileType: "pdf",
        mimeType: "application/pdf",
      },
    },
    json: {
        "attachmentCount": 3,
      "@odata.etag": '..."',
      bccRecipients: [],
      body: {
        content:
          '...',
        contentType: "html",
      },
      bodyPreview:
        "...",
      categories: [],
      ccRecipients: [],
      changeKey: "...",
      conversationId:
        "...",
      conversationIndex: "...",
      createdDateTime: "2025-06-02T16:20:28Z",
      flag: {
        flagStatus: "notFlagged",
      },
      from: {
        emailAddress: {
          address: "user1@mail.com",
          name: "user1",
        },
      },
      hasAttachments: true,
      id: "...",
      importance: "normal",
      inferenceClassification: "focused",
      internetMessageId:
        "...",
      isDeliveryReceiptRequested: null,
      isDraft: false,
      isRead: false,
      isReadReceiptRequested: false,
      lastModifiedDateTime: "2025-06-03T09:44:46Z",
      parentFolderId:
        "...",
      receivedDateTime: "2025-06-02T16:20:28Z",
      replyTo: [],
      sender: {
        emailAddress: {
          address: "user1@mail.com",
          name: "user1",
        },
      },
      sentDateTime: "2025-06-02T16:19:46Z",
      subject: "Fwd: Hi",
      toRecipients: [
        {
          emailAddress: {
            address: "user2@mail.com",
            name: "user2",
          },
        },
      ],
      webLink:
        "https://outlook.live.com/owa/",
    },
    pairedItem: {
      item: 0,
    },
  },
];

return newItems;

Methods for working with DeepOpinion metadata

MethodDescription
$execution.idThe unique ID of the current workflow execution.
$execution.modeWhether the execution was triggered automatically, or by manually running the workflow. Possible values are test and production.
$execution.resumeUrlThe webhook URL to call to resume a workflow waiting at a Wait node.
$(“node name”).isExecutedCheck whether a node has already executed.
$prevNode.nameThe name of the node that the current input came from. When using the Merge node, note that $prevNode always uses the first input connector.
$prevNode.outputIndexThe index of the output connector that the current input came from. Use this when the previous node had multiple outputs (such as an If or Switch node). When using the Merge node, note that $prevNode always uses the first input connector.
$prevNode.runIndexThe run of the previous node that generated the current input. When using the Merge node, note that $prevNode always uses the first input connector.
$runIndexHow many times DeepOpinion has executed the current node. Zero-based (the first run is 0, the second is 1, and so on).
$workflow.activeWhether the workflow is active (true) or not (false).
$workflow.idThe workflow ID.
$workflow.nameThe workflow name.

more to come…