The moment it happens
Send thank-you emails from the right mailbox for each brand
New buyers get a thank-you from your Gmail or your Outlook, depending on which brand they bought from.
- Runs
- The moment it happens
- Apps
- Gmail, Outlook
- AI
- Not needed
- Access
- gmail.send; Mail.Send
Send this to your assistant
Create a ClickRuntime automation: when a sale comes in, send the buyer a thank-you email. Use my Gmail for Northwind Candles orders and my Outlook for Acme Workshop orders.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A maker runs two small brands: one on Google Workspace, the other on Microsoft 365. Customers should hear from the brand they bought from, but sending thank-yous by hand from two different mailboxes means some are forgotten and a few go from the wrong address.
Picking the right mailbox for each sale keeps every brand's emails consistent, and makes sure every customer gets their thank-you.
What you get out of it
Every customer hears from the right brand
The thank-you comes from the address the customer knows, so replies reach the right inbox.
No forgotten emails
Every sale gets a thank-you, from either brand, without a reminder.
One automation for both
One setup covers both mailboxes, rather than two separate tools.
Each sale handled once
Repeated sale notices are recognised and ignored.
How it works
What happens, step by step
Your store tells ClickRuntime the moment a sale is made.
It checks the sale has not been handled already.
It works out which brand the sale belongs to.
A thank-you email goes to the buyer from that brand's mailbox, Gmail or Outlook.
Before it runs live
- Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
- Connect Outlook
- Paste your automation's link into the other app's webhook settings
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Act only on the items that match your own rules, and skip the rest
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Gmail and Outlook steps into one automation
Under the hood
The code that runs this automation
import base64
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, http, credentials, state
api = lambda name, version: build(name, version, credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
def send_gmail(to, subject, text):
raw = base64.urlsafe_b64encode(f"To: {to}\r\nSubject: {subject}\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n{text}".encode()).decode()
api("gmail", "v1").users().messages().send(userId="me", body={"raw": raw}).execute()
def graph(method, path, **kw):
r = http.request(method, "https://graph.microsoft.com/v1.0" + path, headers={"Authorization": f"Bearer {credentials.connection('microsoft', 'work')}"}, **kw)
return r.raise_for_status() or (r.json() if r.content else None)
def send_mail(to, subject, text):
graph("POST", "/me/sendMail", json={"message": {"subject": subject, "body": {"contentType": "Text", "content": text},
"toRecipients": [{"emailAddress": {"address": a}} for a in to.split(",")]}})
@on_event
def handle(event):
sale = event.json or {}
if state.get(f"sale:{event.event_id}"):
return {"duplicate": True}
first = (sale.get("name") or "there").split()[0]
if sale.get("store") == "northwind-candles":
send_gmail(sale["email"], "Thank you from Northwind Candles", f"Hi {first},\n\nThank you for your order. We hope you love it!\n\nNorthwind Candles")
mailbox = "gmail"
else:
send_mail(sale["email"], "Thank you from Acme Workshop", f"Hi {first},\n\nThanks for your order. Reply here with any questions.\n\nAcme Workshop")
mailbox = "outlook"
state.set(f"sale:{event.event_id}", mailbox)
return {"sent_from": mailbox}FAQ
Common questions
How does it know which brand a sale is for?
Can each brand have its own wording?
Which stores does it work with?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Triage your Gmail and Outlook inboxes with one digest
Both inboxes are sorted into the same categories, and you get one digest of the emails that need you.
See how it worksSummarise PDF attachments arriving in Gmail or Outlook
When a PDF arrives in either your Gmail or your Outlook, you get an email with a short summary of what it says.
See how it worksCheck whether your emails land in the inbox at Gmail and Outlook
Every week a test email is sent each way between your Gmail and Outlook, and you learn whether it reached the inbox or spam and whether SPF, DKIM and DMARC passed.
See how it worksKeep exploring
Set up “Send thank-you emails from the right mailbox for each brand” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.