Skip to content

The moment it happens

Check VAT numbers on Stripe invoices and email the right person

When Stripe drafts an invoice, an invalid VAT number is flagged to finance; when it's finalised, the customer gets an email from you.

Runs
The moment it happens
Apps
Gmail, Stripe
AI
Not needed
Access
Stripe read invoices/customers; gmail.send

Send this to your assistant

Create a ClickRuntime automation: when a Stripe invoice is drafted, re-check the customer's EU VAT number with VIES and email finance if it's invalid; when it's finalised, email the customer from my 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 software company bills European business customers through Stripe and applies the reverse charge when a customer gives a valid VAT number. VAT numbers lapse when companies restructure or close, and an invoice issued without VAT to an invalid number is a tax problem that surfaces months later at audit.

This automation re-checks the VAT number against the EU's VIES service each time Stripe drafts an invoice, while there is still time to fix it, and emails finance if it no longer validates. When the invoice is finalised, the customer receives a short personal email from your Gmail with the link to view and pay it.

What you get out of it

  • Problems caught before invoicing

    An invalid VAT number is flagged while the invoice is still a draft and can be corrected.

  • Less audit risk

    Reverse-charge invoices are only issued against numbers that validated at the time.

  • Finance only hears about exceptions

    Valid numbers pass quietly; only failures produce an email.

  • A personal invoice email

    Customers receive the invoice link from your address, which tends to get faster replies than a system email.

  • A record of each check

    Finance emails include the number checked and the result, which helps when answering questions later.

How it works

What happens, step by step

  1. When Stripe drafts or finalises an invoice, it tells ClickRuntime straight away, and the message is checked to be genuinely from Stripe.

  2. For a draft invoice, it reads the customer's EU VAT number and checks it with the EU's VIES service.

  3. If the number is invalid or cannot be checked, finance gets an email with the customer and invoice details.

  4. For a finalised invoice, the customer gets an email from your Gmail with the link to view and pay it.

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 Stripe
  • Paste your automation's link into the other app's webhook settings

What you get

RunsThe moment it happens
Check VAT numbers on Stripe invoices and email the right personjust nowSucceeded
Email · FinanceVAT check failed: Contoso GmbH. VAT number DE123456789 did not validate for draft invoice in_1Q2w3E.

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 Gmail and Stripe 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.
invoice_notices_and_vat_checks.pyexample
import base64
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
import stripe
from clickruntime import on_event, credentials, verify, http

def send(to, subject, text):
    msg = EmailMessage(); msg["To"], msg["Subject"] = to, subject; msg.set_content(text)
    g = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
    g.users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()

@on_event
def handle(event):
    if not verify.stripe(event.body, event.header("Stripe-Signature"), credentials.secret("STRIPE_WEBHOOK_SECRET")):
        return {"ignored": "bad signature"}
    inv = event.json["data"]["object"]
    if event.json["type"] == "invoice.finalized":
        send(inv["customer_email"], f"Invoice {inv['number']}", f"Hello,\n\nYour invoice is ready: {inv['hosted_invoice_url']}\n\nThank you.")
        return {"sent": "customer"}
    stripe.api_key = credentials.secret("STRIPE_API_KEY")
    vat = next((t for t in stripe.Customer.list_tax_ids(inv["customer"]).data if t.type == "eu_vat"), None)
    if not vat:
        return {"vat": None}
    r = http.post("https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number", json={"countryCode": vat.value[:2], "vatNumber": vat.value[2:]})
    if r.status_code != 200 or not r.json().get("valid"):
        send("finance@example.com", f"VAT check failed: {inv.get('customer_name')}", f"VAT number {vat.value} did not validate for draft invoice {inv['id']}.")
    return {"vat": vat.value, "status": r.status_code}

FAQ

Common questions

Which customers are checked?
Customers with an EU VAT number saved as a tax ID in Stripe. Customers without one are skipped.
What if the VIES service is down?
VIES is sometimes unavailable for individual countries. In that case finance gets an email saying the check could not be completed, so they can try again before finalising.
Does it change the invoice?
No. It only checks and emails. Any change to tax on the invoice is made by finance in Stripe.
What permissions does it need?
Stripe read invoices/customers; 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 “Check VAT numbers on Stripe invoices and email the right person” from your assistant

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