Skip to main content

E-mail

Folder examples/E-Mail. Almost all of them need a mail account: see Mail sending and Mailbox in the overview. The addresses in the examples are placeholders.

AI Auto Answer​

Intermediate examples/E-Mail/AI Auto Answer

Starts with every new e-mail in the inbox. A language model answers the question in the mail as a short e-mail, using a fixed text as its facts (a party at the barn, no cars allowed), and the answer is sent back to the sender. If the AI step fails the diagram ends without sending anything. The idea is explained in Automatic answers with AI.

Needs: a language model; a mailbox (the event) and mail sending.

Prompt

Create a diagram that starts on every new e-mail in the INBOX folder. Let the language model answer the question in the mail as a short e-mail, using only this text as its facts: "There is a party by the barn, no cars allowed." Send the answer to the sender. If the AI step fails, end the diagram without sending anything.

Filter and Sort​

Intermediate examples/E-Mail/Filter and Sort

Starts for every unread mail in the inbox and checks the text against a regular expression for the words keyword1, keyword2 and text3. A mail that matches is moved to the folder Filtered, the others stay. The diagram listens for five minutes: a timer event leads to a join where the main path waits, and then it ends. See Decision and Event node.

Needs: a mailbox with the folder Filtered.

Prompt

Create a diagram that starts for every unread e-mail in the INBOX folder and matches the mail text against the regular expression \b(?:keyword1|keyword2|text3)\b with a regex decision. A mail that matches is moved to the IMAP folder "Filtered", others are left alone. Stop listening after five minutes: a timer event of 5 minutes leads to a join where the main path waits and then ends the diagram.

Support Inbox Triage​

Intermediate examples/E-Mail/Support Inbox Triage

A robot for a shared inbox. A language model classifies each new mail with one word: invoice, customer or newsletter. Invoices are moved to the folder invoice and forwarded to accounting, newsletters to newsletter, everything else to customer, where the language model drafts a polite reply that is sent to the sender. The use case is described in Support inbox triage.

Needs: a language model; a mailbox with the folders invoice, newsletter and customer; mail sending; replace accounting@example.com.

Prompt

Create a robot that starts on every new e-mail, lets the language model classify it as exactly one word (invoice, customer or newsletter, temperature 0.1) and branches on the answer: for "invoice" move the mail to the folder invoice and forward it to accounting@example.com, for "newsletter" move it to the folder newsletter, in all other cases move it to the folder customer, let the language model draft a short polite reply that promises nothing and send it to the sender. Name the branches "is invoice" and "is newsletter" and put the conditions in the parameters of the edges. If the classification fails, end the diagram.

Approval by E-Mail​

Intermediate examples/E-Mail/Approval by E-Mail

A manager gets a mail with two links, approve and reject. The run sleeps until a link is clicked. The applicant is told the result. If nobody answers within three days a timer wakes the diagram and the manager is reminded. The use case is described in Approvals by e-mail, the technique in Send E-Mail and Click response.

Needs: mail sending, and the hostname in the system settings (the links in the mail point to it); replace manager@example.com and applicant@example.com.

Prompt

Build an approval flow: a wake-up timer of 3 days with "sleep later" and the action "timeout", then an e-mail to manager@example.com with the subject "Please approve: purchase request" and two links ${action.approve} and ${action.reject}. Behind the mail a click response decision with the edges "approve", "reject" and "timeout". "approve" sends the applicant@example.com an e-mail "Your request was approved", "reject" an e-mail "Your request was rejected", "timeout" reminds the manager that nobody answered for three days. All three end the diagram.

Double Opt-In​

Intermediate examples/E-Mail/Double Opt-In

Double opt-in: reads persons from the example addresses and sends each a confirmation mail ("Click on the link to subscribe") with a yes and a no link. The mail of each person waits for its own answer in a parallel path for up to two minutes. yes writes the person to email_accept.csv; no and a timeout write it to email_decline.csv. See Wakeup Timer with sleep later.

Needs: mail sending and the hostname; the example data examples/Data/address/Fictional addresses.csv. The addresses of the persons are made up (Forename@Surname): run it as a dry run.

Prompt

Create a double opt-in. Read the persons of examples/Data/address/Fictional addresses.csv row by row. For each person fork a parallel path: a wake-up timer of 2 minutes with "sleep later" and the action "timeout", then an e-mail with the answer links ${action.yes} (subscribe) and ${action.no} (unsubscribe), greeting the person as Mr. or Mrs. depending on the Gender column. A click response decision follows: "yes" appends the person to email_accept.csv, "no" and "timeout" append it to email_decline.csv. The main path goes on with the next row; when no row is left the diagram ends.

Welcome New Customers​

Intermediate examples/E-Mail/Welcome New Customers

Reads new customers one by one and sends each a welcome mail, in German for customers from Germany and in English for everyone else. The use case is described in Onboarding and newsletters.

Needs: mail sending; the example data examples/Data/address/Fictional addresses.csv. The recipients are constructed (forename.surname@example.com): run it as a dry run.

Prompt

Create a diagram that reads the customers of examples/Data/address/Fictional addresses.csv (Forename, Surname, Gender, Country) row by row. For each row a decision named "is German" with the condition ${Country} == 'Germany' sends a welcome mail in German ("Willkommen, Vorname!"), all other rows a welcome mail in English ("Welcome, forename!"). Address the mail to forename.surname@example.com. Then go on with the next row, and end when no row is left.

Escalation Ladder​

Advanced examples/E-Mail/Escalation Ladder

An alert that does not give up. First an e-mail to the person on call with a link I got it. If nobody clicks within 15 minutes, a Telegram message follows, and after another 15 minutes a browser push to the team lead. As soon as someone confirms by e-mail the diagram ends. The team lead's browser must be coupled before the ladder starts, so the first step is an input page with a Push subscription field. The use case is described in Reminders and escalation.

Needs: mail sending and the hostname; a Telegram bot (and the id of the chat, a placeholder here); browser push (https and keys in your account settings). The run waits at the first step until someone has coupled the browser.

Prompt

Build an escalation ladder. Start with an input page with one required field "push.subscription" of the type Push subscription, where the team lead couples the browser. Then a wake-up timer of 15 minutes with "sleep later" and the action "timeout", an e-mail to oncall@example.com with the subject "Alert: please confirm" and a link ${action.ack}, and a click response decision with the edges "ack" and "timeout". "ack" ends the diagram ("Someone confirmed"). "timeout" sends a Telegram message to the chat 123456789 ("Nobody confirmed the alert by e-mail. Please look at it."), waits another 15 minutes and sends a browser push to the team lead ("Alert not confirmed"), followed by a second click response decision with "ack" (ends "Someone confirmed") and "timeout" (ends "Nobody answered").