Portal Community

message/markAsUnread

Add the UNREAD label to a Gmail message, restoring its unread state programmatically.

When to Use

Configuration

Connection

FieldTypeDescription
credentialIdGuid requiredOAuth2 credential ID from BizFirst Credentials Manager. Requires gmail.modify scope.

Operation Fields

FieldTypeDefaultDescription
messageIdstring requiredGmail message ID to mark as unread. Adds the system UNREAD label.

Sample Configuration

{
  "nodeType": "Gmail",
  "operation": "message/markAsUnread",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{needsHumanReview.messageId}}"
}

Validation Errors

ErrorCauseResolution
MISSING_FIELD: messageIdmessageId is emptyEnsure upstream node provides a valid message ID
MESSAGE_NOT_FOUNDMessage does not exist in the accountVerify message ID comes from the authenticated account
INVALID_CREDENTIALOAuth token expired or credential not foundRe-authenticate in BizFirst Credentials Manager
PERMISSION_DENIEDCredential lacks gmail.modify scopeRe-grant OAuth permissions with the correct scope

Output

Success Port

FieldTypeDescription
successbooltrue when the UNREAD label was added
statusstringsuccess
errorCodestringEmpty on success

Error Port

On failure, routes to the error port with status: "error", errorCode, and errorMessage.

Sample Output

{
  "success": true,
  "status": "success",
  "errorCode": ""
}

Expression Reference

ExpressionResolves ToExample Use
{{needsHumanReview.messageId}}Message ID routed to human review queuemessageId field
{{catchBlock.failedMessage.messageId}}Message ID from a failed downstream nodeRe-queue via markAsUnread
{{slaReset.targetMessageId}}Message ID for SLA clock resetSLA re-queue operation

Node Policies & GuardRails

PolicyRule
IdempotencyCalling markAsUnread on an already-unread message is safe — it is a no-op with a success response
Infinite Loop RiskDo not use markAsUnread in a polling workflow without a separate re-processing flag — it can cause the same email to be processed infinitely
Credential StorageStore OAuth credentials in BizFirst Credentials Manager — never hardcode tokens in workflow configuration
Quota ManagementmarkAsUnread (modify) costs minimal quota units — safe for batch and frequent use
State SignalingUse a dedicated workflow state variable or label in addition to unread status for reliable re-processing logic
Test IsolationTest mark-as-unread workflows against a dedicated Gmail test account before connecting production

Examples

Example 1: Flag for Human Review

A classification node detects an email requires human intervention — mark it as unread to surface it in the agent's inbox.

{
  "nodeType": "Gmail",
  "operation": "message/markAsUnread",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{classifier.escalationMessageId}}"
}

Example 2: Error Recovery Re-Queue

A CatchBlock detects a downstream processing failure and re-queues the source email by marking it unread.

{
  "nodeType": "Gmail",
  "operation": "message/markAsUnread",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{catchBlock.sourceMessageId}}"
}

Example 3: Deferred Processing Signal

A rate-limiting check determines the workflow cannot process more messages this cycle — mark remaining as unread for the next run.

{
  "nodeType": "Gmail",
  "operation": "message/markAsUnread",
  "credentialId": "a3f9d12b-44e1-4c89-b7d2-9f0a1e2b3c4d",
  "messageId": "{{loop.current.messageId}}"
}