Gmail
The Gmail connector reads threads from a Gmail or Google Workspace mailbox, sends mail and replies, and adds or removes labels. Mention it as @email_gmail. Each run can take the next thread from the mailbox as a pipeline item, so an Unstract Flow workflow works through an inbox: each run claims threads one at a time and keeps going until none are left.
Connect
The credential is an OAuth sign-in. In the credential dialog, enter a Credential Name, select Connect with Google, and sign in to Google in the pop-up window. Flow asks for permission to read, send and label mail. Connectors, instances and credentials covers the rest of the setup.
| Setting | Default | What it does |
|---|---|---|
| Thread Filter | is:inbox | A Gmail search that limits which threads the workflow sees. For example, is:inbox from:billing@example.com. Saved empty, the workflow sees every thread outside Spam and Trash, Sent included. An instance that existed before is:inbox became the default and never saved this setting was given an empty filter: it still sees every thread until someone saves one. A step's own search is combined with it: a step finds only threads that match both. |
What a step can do
| Action | What it does |
|---|---|
claim_next_thread | Claims the next thread: one queued again by a new message in the last 24 hours first, then the available thread that entered the pipeline first. A thread queued again more than 24 hours ago comes after all of them. |
list_threads | Looks at the newest threads that match a search, as many as the step asks for (one by default). It returns those that aren't done, Failed or in use, and adds new ones to the pipeline. A step that asks for threads in a pipeline state instead lists those threads and doesn't look at the mailbox. |
get_thread | Reads a thread's messages and saves its attachments to the run's files. Zip, tar and .eml attachments are unpacked. When two attachments in a thread share a file name, the second is saved as scan (1).pdf, and so on. An attachment that is no longer in the mailbox, or that Gmail refuses to send, is left out, and the step's extraction_warnings names it. When Gmail is busy, the read fails and the thread is given back. |
send_message | Sends a new message, or replies inside a thread. Give a reply the thread's subject, or it starts a new conversation. Attach a file from the run's files by its path, such as a PDF an earlier step made: up to 20 files, 25 MB in total. The step fails at the first file that goes over the limit, before it reads that file. A file given as its content instead passes through the workflow, which holds all of it in memory, so give a large file by its path. |
set_flag | Adds or removes labels on a thread. |
refresh_pipeline | Looks for new threads, and for new messages on threads already processed. |
mark_thread_processed | Marks a claimed thread Success or Failed when the run has finished with it. |
Take the next thread from @email_gmail. Read the attached invoice PDF. When you're done, remove the
UNREADlabel and reply to the sender that the invoice was received.
How runs read the mailbox
Unstract Flow reads the mailbox only while a run is going; nothing watches it between runs. A run claims a thread that has had a new message in the last 24 hours since it was processed, if there is one, and otherwise the available thread that entered the pipeline first. It reads it, and the thread moves to Staged. When the run has finished with it, the thread is marked Success or Failed.
Each check for new threads reads every thread that matches the Thread Filter, up to 5,000, and queues them oldest first. Set the filter to what the workflow should see, such as is:inbox after:2026/10/06. Put a start date in it to process only new mail. Avoid is:unread if people read this mailbox: a thread someone opens before the next check can be missed.
A thread marked Success is queued again when a new message arrives on it, including one marked done without being read: a message that arrived after it was marked done is new, one from before isn't. A check sees a new message only while the thread still matches the Thread Filter. A reply the workflow sent, or a label it changed, doesn't queue it. With is:unread in the filter, a reply someone reads in Gmail before the next check doesn't queue the thread. A thread marked Failed stays Failed: no run claims it again, and a new message on it doesn't queue it. When reading a thread fails because the mail service is busy or unavailable, or the mailbox sign-in fails, the thread isn't marked Failed: the run gives it back, and a retry or the next run reads it. Each time, the thread waits 5 minutes before claim_next_thread offers it again, so the other threads go first. When every thread left is waiting, the claim takes nothing and its message says how many wait; a run after the wait picks them up. A retry that fails during those 5 minutes isn't counted. The third counted failure in a row marks it Failed with the error. To process a Failed thread again, select Reset Status on it.
- If a run stops after claiming a thread, the thread stays Claimed, or Staged once the run has read it. To process it again, someone with the Owner, Admin or Member role selects Release claims in the run's details, or Reset Status on the thread. Release claims returns a Staged thread only with Also release items this run already read or finished ticked, since the run may already have replied to it. Once the claim is 8 hours old and its run has ended, a Claimed thread is marked Failed, and so is a Staged one when its run ended Failed or Cancelled; the check runs every 5 minutes. After a run that ended Succeeded or Partial, a Staged thread stays Staged until someone releases or resets it.
- A message the mailbox's owner sent never queues a processed thread again, even one sent to the mailbox itself. Otherwise the workflow's own reply on such a thread would queue it on every check.
- A workflow prepared before
mark_thread_processedexisted doesn't call it, so its threads stay Staged and a new message doesn't queue them again. Prepare the workflow again. To process one thread again by hand, open its pipeline tab in the editor, under Email, and select Reset Status on it. - A step can't ask for the next thread that matches a search. Which threads enter the pipeline is decided by the Thread Filter and by the search a step gives
refresh_pipelineorlist_threads. A thread a step reads withget_threadenters the pipeline too. - A label is named as it appears in Gmail, such as
Invoices, or by its Gmail label ID. A step that names a label the mailbox doesn't have fails, and the message lists the mailbox's labels.