Skip to content

The moment it happens

Save a PDF receipt to S3 for each payment and email the link

When a payment succeeds, a PDF receipt is created, stored in your S3 bucket, and the customer gets an email from your Gmail with a private download link.

Runs
The moment it happens
Apps
AWS, Gmail
AI
Not needed
Access
s3:PutObject/GetObject; Gmail send

Send this to your assistant

Create a ClickRuntime automation: when Stripe sends a successful payment to this link, generate a PDF receipt, upload it to S3, and email the customer a 7-day download link from Gmail.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

A business taking payments wants every receipt stored somewhere it controls, for accounting and for customers who ask for a copy months later. The payment provider's own receipts are fine until you need them in bulk, or for a customer who lost the email.

Generating a receipt, keeping it in S3 and emailing the customer a private link means every payment has a stored document and the customer has their copy straight away.

What you get out of it

  • Every receipt kept

    A PDF for each payment sits in your bucket, ready for your accountant or an audit.

  • Customers get their copy at once

    The email arrives seconds after payment, from your own address.

  • Private by default

    Links expire after seven days, and the file stays private in S3.

  • Easy re-sends

    When a customer asks for a copy later, it's already stored under their payment.

How it works

What happens, step by step

  1. Stripe sends each successful payment to your automation's link.

  2. ClickRuntime builds a simple PDF receipt with the customer, amount, date and reference.

  3. It saves the PDF to your S3 bucket under the payment reference.

  4. It emails the customer a 7-day download link from your Gmail address.

Before it runs live

  • Connect AWS
  • Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Save a PDF receipt to S3 for each payment and email the linkjust nowSucceeded
Gmail · SentYour receipt from Northwind – Thanks for your payment of 249.00 USD. Download your receipt (link valid 7 days)…

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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 AWS and Gmail steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
store_generated_pdfs_in_s3_and_email_the_link.pyexample
import base64, boto3
from datetime import datetime, timezone
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_event, credentials, http
REGION, BUCKET = "us-east-1", "northwind-files"

def aws(service):
    return boto3.client(service, region_name=REGION, aws_access_key_id=credentials.secret("AWS_ACCESS_KEY_ID"),
                        aws_secret_access_key=credentials.secret("AWS_SECRET_ACCESS_KEY"))

def pdf(lines):
    text = " ".join(f"BT /F1 12 Tf 72 {720 - 20 * i} Td ({l.replace('(', '[').replace(')', ']')}) Tj ET" for i, l in enumerate(lines))
    objs = ["<</Type/Catalog/Pages 2 0 R>>", "<</Type/Pages/Kids[3 0 R]/Count 1>>", "<</Type/Page/Parent 2 0 R/MediaBox[0 0 612 792]/Contents 4 0 R/Resources<</Font<</F1 5 0 R>>>>>>",
            f"<</Length {len(text)}>>stream\n{text}\nendstream", "<</Type/Font/Subtype/Type1/BaseFont/Helvetica>>"]
    return ("%PDF-1.4\n" + "".join(f"{i} 0 obj{o}endobj\n" for i, o in enumerate(objs, 1)) + "trailer<</Root 1 0 R>>\n%%EOF").encode()

@on_event
def handle(event):
    pi = event.json["data"]["object"]
    email = pi.get("receipt_email") or pi["metadata"].get("email")
    when = datetime.fromtimestamp(pi["created"], timezone.utc).date()
    key = f"receipts/{when}/{pi['id']}.pdf"
    s3 = aws("s3")
    s3.put_object(Bucket=BUCKET, Key=key, ContentType="application/pdf", Body=pdf(["Northwind Ltd - Receipt", f"Date: {when}", f"Reference: {pi['id']}",
                  f"Amount: {pi['amount_received'] / 100:,.2f} {pi['currency'].upper()}", f"Customer: {email}"]))
    link = s3.generate_presigned_url("get_object", Params={"Bucket": BUCKET, "Key": key}, ExpiresIn=7 * 24 * 3600)
    msg = EmailMessage()
    msg["To"], msg["Subject"] = email, "Your receipt from Northwind"
    msg.set_content(f"Thanks for your payment of {pi['amount_received'] / 100:,.2f} {pi['currency'].upper()}.\n\nDownload your receipt (link valid 7 days):\n{link}")
    build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()
    return {"key": key}

FAQ

Common questions

What's on the receipt?
Your business name, the customer, the amount and currency, the payment date and the payment reference.
What does the Stripe webhook need?
A webhook for payment_intent.succeeded pointing at your automation's link, with Stripe signature checking turned on in your ClickRuntime dashboard.
Can it attach the PDF instead of a link?
Yes. Ask for the PDF to be attached to the email as well as stored in S3.
What permissions does it need?
s3:PutObject/GetObject; Gmail send. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run for each event the app sends.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Save a PDF receipt to S3 for each payment and email the link” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.