PostHog Handbook Library / Growth

2,182 words. Estimated reading time: 10 min.

Automations

Auto TL;DR

At a Glance

This long page covers these main areas. The list is generated from the article headings, so it updates with every handbook rebuild.

  1. Connecting everything together
  2. Vitally Segmentation
  3. Vitally Zendesk/HubSpot Automation
  4. Ensuring that Vitally Accounts have corresponding Zendesk Organization and HubSpot Companies associated with them
  5. Tagging Zendesk Organizations based on Segment and Subscription information
  6. Setting the correct organization in Zendesk for new tickets
  7. [Deprecated] HubSpot and Zendesk tagging
  8. Billing trial activated event HubSpot and Zendesk

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:

  1. Segment Name: $60K ARR
  1. Segment Name: $20K ARR
  1. Segment Name: Startup Plan
  1. Segment Name: Annual Plan
  1. Segment Name: Active Trial
  1. Segment Name: First payment forecasted this month

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:

The Zap then:

  1. Tries to find a HubSpot contact matching the email
  2. If successful, looks up the associated HubSpot Company
  3. Sets the posthog_organization_id property in HubSpot so that Vitally will be able to link to the Company
  4. Creates a Zendesk Organization with the following properties:

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:

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:

The Zap then updates the specific Zendesk Organization with the requested tags.

  1. Zendesk Tag: priority_customer
  1. Zendesk Tag: paying_customer
  1. Zendesk Tag: non_paying
  1. Zendesk Tag: churned
  1. Zendesk Tag: startup_plan
  1. Zendesk Tag: trial

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:

[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).

  1. Looks up the associated email in Clearbit
  2. Continues only if there is an associated Company in the Clearbit payload
  3. 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)
  4. Finds the Company by name in HubSpot
  5. Sets the Organization ID and Trial end date in HubSpot.
  6. 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:

  1. HubSpot Inbound Hands-on Deal Closed to Renewal Deal (Zapier automation details)
  2. HubSpot PQL Hands-on Deal Closed to Renewal Deal (Zapier automation details)
  3. HubSpot Renewal Deal Closed to Renewal Deal (Zapier automation details)

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:

  1. Looks up the PostHog Distinct ID via the email address of the person
  2. 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:

  1. Transforms the HubSpot ID of the Pipeline and Stage to the names via lookup tables and only carries on if matches are found
  2. Gets the Deal Contact and Owner information
  3. 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:

  1. Order Form ID
  2. Customer Email
  3. Customer Address
  4. Company Domain
  5. Contract Start Date
  6. Contract Term (months)
  7. Credit Amount
  8. Discount
  9. 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:

  1. Start Date
  2. Term (months)
  3. Credit Amount
  4. 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

  1. Accepts the following inputs:
  2. Company name (required)
  3. Domain (required)
  4. Tags
  5. Organization ID
  6. Instance
  7. Startup plan or Trial ends at
  8. Formats tags and startup/trial ends at in case of missing data
  9. Formats startup/trial end in YYYY-MM-DD
  10. Creates or Updates an organization with the information above

Apply Stripe Credit

This Zap applies credit and associated metadata to a Stripe Customer object

  1. Accepts the following inputs:
  2. Duration (e.g. 1 year or 6 months)
  3. Stripe Customer ID
  4. Amount (dollars)
  5. Description (optional)
  6. Credit start date
  7. Is startup credit
  8. Calculates the credit end date from the Start Date + Duration
  9. Converts Dollars to Cents (for Stripe)
  10. Adds the credit balance via the Stripe API
  11. Updates the following metadata on the Customer Object:
  12. credit_expires_at
  13. is_startup_plan_customer

Canonical URL: https://posthog.com/handbook/growth/sales/automations

GitHub source: contents/handbook/growth/sales/automations.md

Content hash: 1154eaae616a30b2

Static reader notes
  • MDX_COMPONENT_STATIC_ADAPTER: Adapted interactive MDX components for static reading: PrivateLink.