Automations
As Vitally connects all of our Product, Stripe, Zendesk and HubSpot data together it's the best place to trigger automations via Playbooks. These Playbooks can call a webhook after Accounts or Users meet certain criteria. This allows us to call out to Zapier to use their inbuilt actions to update Zendesk, HubSpot, Slack and more. We use Zapier extensively throughout the company for automation. There is a shared Zapier login in 1Password.
Connecting everything together
Vitally requires a consistent external_id
to be present to link everything together. For Accounts, we use the posthog_organization_id
and for Users it's their email
.
Vitally Segmentation
Vitally uses Playbooks to put Accounts and Users into Segments, which are useful for reporting as well as targeting of Playbooks. We have the following Segmentation Playbooks defined:
- Segment Name: $60K ARR
- Playbook Link
- Criteria
- Account not in Startups Segment
- ARR >= $60K
- Segment Name: $20K ARR
- Playbook Link
- Criteria
- Account not in Startups Segment
- ARR >= $20K AND ARR < $60K
- Segment Name: Startup Plan
- Playbook Link
- Used to track companies either on PostHog for Startups or the YC Program
- Criteria
- Stripe Account Balance < 0 (e.g. they have credit remaining)
- Stripe Credit Expires at > 0 days from today (e.g. it hasn't expired yet)
- Stripe Is Startup Plan Metadata is not false or null (e.g. they haven't been marked as being on a paid annual plan)
- Segment Name: Annual Plan
- Playbook Link
- Criteria
- Stripe Subscription interval is yearly
- OR
- Stripe Account Balance < 0 (e.g. they have credit remaining)
- Stripe Credit Expires at > 0 days from today (e.g. it hasn't expired yet)
- Stripe Is Startup Plan Metadata is false or null (e.g. they haven't been marked as being on the startup plan)
- Segment Name: Active Trial
- Playbook Link
- Criteria
- Free Trial Until is greater than 0 days from now (comes from the Billing Postgres connection)
- Segment Name: First payment forecasted this month
- Playbook Link
- Criteria
- Lifetime Value (LTV) is 0 (e.g. they have never paid us)
- Stripe current period end is greater than 0 days from now
- Forecasted MRR > $1
Vitally -> Zendesk/HubSpot Automation
As Vitally has Subscription/Segment information it's the best place to drive Zendesk tagging and other activities.
Ensuring that Vitally Accounts have corresponding Zendesk Organization and HubSpot Companies associated with them
The New Orgs to Zendesk and HubSpot via Zapier playbook triggers on Accounts where there is no associated Zendesk ID but there is a Stripe Customer email, so that we can look up the contact and company information in HubSpot. When these criteria are matched the playbook sends the following traits to a webhook which triggers the Vitally Webhook to New Zendesk Org and HubSpot Zap:
- orgName - PostHog Organization Name
- orgID - PostHog Organization ID
- customerID - Billing Customer ID
- email - Stripe Email
- siteURL - the URL of the PostHog Cloud they're on (useful to have in Zendesk)
The Zap then:
- Tries to find a HubSpot contact matching the email
- If successful, looks up the associated HubSpot Company
- Sets the posthog_organization_id property in HubSpot so that Vitally will be able to link to the Company
- Creates a Zendesk Organization with the following properties:
name
- Billing Customer ID - PostHog Organiation Name (e.g. 12345 - PostHog) which guarantees uniquenessexternal_id
- PostHog Organization IDph_external_id_org
- PostHog Organization ID custom field (becauseexternal_id
cannot be used in triggers and automations)domain
- The domain name from the HubSpot Company Object (which might not exist - see below)
There are some scenarios (e.g. gmail signups) where HubSpot doesn't have an associated company record and as such there won't be a domain to supply to Zendesk. In this case the automation completes but also adds the Email and Zendesk org information to the Zendesk Orgs Without a Domain table. For each row there are two buttons:
- Add Domain to Org - Will fire a Zap to extract the company name from the email and set it on the Zendesk Organization. Use this one if it's clearly the right company domain.
- Add User to Org - Will fire a Zap which adds that individual user to the Zendesk Organization. Use this if it's a webmail provider (e.g. gmail) as we don't everyone with a @gmail.com email creating tickets for this Organization, but do want this user to get the right level of support for their Organization.
Tagging Zendesk Organizations based on Segment and Subscription information
As Vitally is the best source of truth for Active Subscription / Payment information which informs our Zendesk ticket prioritization, there are a number of Vitally playbooks which will trigger the webhook associated with the Vitally Webhook to Zendesk Tags Zap, passing along the following traits:
- zendesk_id - The Zendesk Organization ID (internal, not external_id)
- playbook name - The tags to set on the Zendesk Organization
The Zap then updates the specific Zendesk Organization with the requested tags.
- Zendesk Tag:
priority_customer
- Playbook Link
- Criteria
- Account is PostHog
- Account not in Startup Plan Segment
- ARR >= $20K
- Zendesk Org ID is set
- Zendesk Tag:
paying_customer
- Playbook Link
- Criteria
- Account not in Startup Plan Segment
- ARR > 0 and < $20K
- Zendesk Org ID is set
- Zendesk Tag:
non_paying
- Playbook Link
- Criteria
- Account is not PostHog
- Account not in Startup Plan or Active Trial Segments
- ARR = 0
- Zendesk Org ID is set
- Zendesk Tag:
churned
- Playbook Link
- Criteria
- Account is not PostHog
- Account not in Active Trial Segment
- Stripe Subscription Status is Cancelled
- Zendesk Org ID is set
- Zendesk Tag:
startup_plan
- Playbook Link
- Criteria
- Account in Startup Plan Segment
- Zendesk Org ID is set
- Zendesk Tag:
trial
- Playbook Link
- Criteria
- Account in Active Trial Segment
- Zendesk Org ID is set
Setting the correct organization in Zendesk for new tickets
Zendesk uses the requester's email domain to associate the ticket and the requester with an organization in Zendesk. To mitigate the problems this causes, we have a Zap named Set user's correct organization ID which:
- Checks each new ticket for a value in the custom ticket field
organization_id
. (This ID is added to each support ticket submitted via our Help sidebarEmail an engineer
form, and community questions.) - Looks for a Zendesk org with an
external_id
which matches the value of the custom ticket fieldorganization_id
- If no match is found, the Zap stops and does nothing
- If a match is found, the Zap sets the user's Zendesk organization accordingly, and then sets an
org-checked
tag to prevent the Zap from running repeatedly on the same ticket.
[Deprecated] HubSpot and Zendesk tagging
The Zaps in this folder have been mostly turned off in favour of the Vitally automations above, however there are some which are still enabled as we need to figure out how to handle them via Vitally.
Billing trial activated event -> HubSpot and Zendesk
This needs to be moved to Vitally
This Zap is triggered when a trial is activated in the Billing UI (triggered by the Billing trial activated action).
- Looks up the associated email in Clearbit
- Continues only if there is an associated Company in the Clearbit payload
- Calls the Update tags on Zendesk org Sub Zap to create/update a Zendesk org with the Name and Domain from Clearbit and Organization ID as the Zendesk External ID (so that it will link the Zendesk org to the Vitally Account)
- Finds the Company by name in HubSpot
- Sets the Organization ID and Trial end date in HubSpot.
- Creates an engagement (Task) in HubSpot for Simon reminding him of the trial end date.
HubSpot Automation
There are three zaps in this folder which create follow-on deals when any hands-on pipeline deal is closed:
- HubSpot Inbound Hands-on Deal Closed to Renewal Deal (link)
- HubSpot PQL Hands-on Deal Closed to Renewal Deal(link)
- HubSpot Renewal Deal Closed to Renewal Deal (link)
They're triggered by a deal closing in the respective pipeline. It figures out the new deal close date based on the term in the existing deal (1,2,3 years) and then creates a new deal in the renewal pipeline, with amounts and ownership copied over too.
Sales Pipeline Events to PostHog
This folder contains Zaps which ensure we are tracking pipeline updates as PostHog events, so that we can model our sales pipeline as a funnel.
Calendly Event Scheduled to PostHog
This Zap is triggered when a new event is created via Calendly, this:
- Looks up the PostHog Distinct ID via the email address of the person
- Captures a
calendly.event_scheduled
event in PostHog with either the Distinct ID above or email address as the Distinct ID if there wasn't a match.
HubSpot Deal Stage Changes to PostHog
This Zap is triggered when a deal stage is updated in HubSpot, this:
- Transforms the HubSpot ID of the Pipeline and Stage to the names via lookup tables and only carries on if matches are found
- Gets the Deal Contact and Owner information
- Captures a
<pipeline-name> <stage-name>
event in PostHog with the Contact email as the Distinct ID
Annual Plan Automation
To ensure consistency in the setup of annual plans we have Zapier Automation to take care of all of the Stripe-related object setup.
Load Contract Details to Annual Plan Table
Once an Order Form is closed in PandaDoc, This Zap will add a new row to the Annual Plan Table with the following information set:
- Order Form ID
- Customer Email
- Customer Address
- Company Domain
- Contract Start Date
- Contract Term (months)
- Credit Amount
- Discount
- Price
Create or Update Stripe Customer
If the Customer has an existing record in Stripe (e.g. they are already subscribed to PostHog) then copy their Customer ID
(starts cus_
) from Stripe to the Stripe Customer ID column. If they don't have an existing Customer in Stripe then
click the Create Stripe Customer button in the table to trigger a Zap to create one. The Zap also automatically adds the ID to the table.
Create Invoice
Once you click the Create Invoice button this Zap will create a Stripe Invoice in draft format. The following table fields need to be populated for this to work so check them before clicking the button:
- Start Date
- Term (months)
- Credit Amount
- Price
Once it's completed it'll populate the table with the Invoice ID and Link. Review this in Stripe, and when you are ready send the Invoice to the customer.
Note: You need to send the invoice to the customer before you apply the credit below. If you apply the credit whilst the Invoice is in a draft state it'll just pay the invoice with the credit, which defeats the purpose
Apply Stripe Credit / Zendesk Tags
Here you can click Apply Credit to trigger a Zap which applies the Stripe Credit and Zendesk tags using the corresponding Sub Zaps. It will apply the priority_customer
tag if the price is above $20k, and paying_customer
otherwise.
Schedule Subscription
If the customer doesn't already have a running monthly subscription this Zap will create one with the desired configuration of paid products. Select the products you want to include and then click the Schedule Subscription button. It'll create a Subscription which is either Scheduled if the Start Date is in the future, or live if it is in the past.
Remember to update the Subscription in the Billing Admin Portal
Note: It has the current default Stripe Price IDs hardcoded in the Zap so if we update those we need to remember to update them in this Zap too.
YC Program
This process is documented in the YC Onboarding section of the handbook.
PostHog for Startups
Work in progress
Sub-Zaps
These are used in a few different places to ensure we do things in a consistent manner. It also ensures repetitive tasks are easy to update if needed.
[Deprecated] Update tags on Zendesk org
Mostly deprecated as we use Vitally for this now
This Zap ensures that a Zendesk org is created and tagged correctly
- Accepts the following inputs:
- Company name (required)
- Domain (required)
- Tags
- Organization ID
- Instance
- Startup plan or Trial ends at
- Formats tags and startup/trial ends at in case of missing data
- Formats startup/trial end in YYYY-MM-DD
- Creates or Updates an organization with the information above
Apply Stripe Credit
This Zap applies credit and associated metadata to a Stripe Customer object
- Accepts the following inputs:
- Duration (e.g. 1 year or 6 months)
- Stripe Customer ID
- Amount (dollars)
- Description (optional)
- Credit start date
- Is startup credit
- Calculates the credit end date from the Start Date + Duration
- Converts Dollars to Cents (for Stripe)
- Adds the credit balance via the Stripe API
- Updates the following metadata on the Customer Object:
credit_expires_at
is_startup_plan_customer