Skip to content

Gmail — Get labels

Type: gmail-get-labels  ·  Package: Gmail v1.0.4  ·  Output: List<Dictionary<string,object>>

Lists the mailbox labels (system ones such as INBOX or UNREAD and custom ones). Use it to find a label’s ID before filtering with labelIds, or to check that a label exists before applying it.

It works on the session created with Gmail — Connect. Pass it in the session parameter, or place this activity inside the body of Gmail — Connect to inherit it automatically.

It returns every label in a single call; it changes nothing.

None.

ParameterTypeDefaultDescription
sessionZoanGmailSession—Gmail — Connect session (inherited inside body).

Returns a List<Dictionary<string,object>>: one item per label, with these keys.

KeyTypeContent
idstringLabel ID. System labels use their name (INBOX, SENT, UNREAD, STARRED, IMPORTANT, SPAM, TRASH, CATEGORY_PROMOTIONS…); custom ones, an ID such as Label_123.
namestringDisplay name. Nested labels include the path: Suppliers/Invoices.
typestringsystem or user.

Loop over it with For each and read by key, for example label["name"] or label["id"].

MessageCause and fix
No Gmail session available. …You didn’t pass session and the activity is not inside Connect’s body.

Find a label’s ID by its name and use it as a filter:

Gmail — Connect credential = credential("gmail-support")
└─ body:
Gmail — Get labels → output: labels
For each label in labels
└─ If condition = str(label["name"]) == "Suppliers"
└─ Set Variable name = suppliersId value = label["id"]
Gmail — Get emails labelIds = suppliersId query = "is:unread" → output: emails