Launch your first workflow
Workflows is currently in early beta. While in beta, workflows is free to use. See the overview page for the proposed pricing model.
We're always looking for feedback to improve workflows, please reach out to us directly in app.
This guide covers creating a very basic workflow where we send an email to users who perform an event on your app or site. Since we are sending a message (email), you will need to set up a messaging channel first.
See the workflow builder for more information on the different components of a workflow, and see the end of this guide for more examples.
- 1
Create a workflow
RequiredGo to Workflows and click the + New workflow button.
This will open the workflow builder:
The new workflow only has two blocks:
- A trigger block: This defines the event that will start the workflow.
- An exit block: This defines the event that will end the workflow.
On the right side of the workflow builder, you can see the types of blocks available to add to your workflow.
- 2
Configure the trigger
RequiredNow, let's click on the trigger block and configure it. In a new workflow, the trigger doesn't have any trigger events. Triggers tell PostHog what events will start the workflow.
Click the + Add trigger event button and search for the event you want to use as the trigger. In this example, we'll use a
pageview
event to send an email to any users who view a page on our website.You can use any PostHog event as a trigger. For example, you could add a button in your app that captures a
test_email
event when clicked.Change the frequency drop down to
"One time"
this means a user cannot be re-enrolled once they are in the workflow - 3
Add an Dispatch
RequiredNow that we have a trigger that can initiate the workflow, we need to add an Dispatch to send a message to the users who trigger the workflow.
Drag an Email dispatch beneath the trigger, into the workflow. Then, click on the email block to configure it.
In the email template, you can configure the following:
- From: A sender address configured in your messaging channel.
- To: The email address of the recipient. By default, it targets the user who's event triggered the workflow.
- Subject: The subject line of the email.
- Preheader: The optional preheader of the email.
- Body: The body of the email. You can use the built in editor to format your email, or you can use a custom template.
During testing, you can hardcode your own email address in the To field for testing.
The email template has access to event and person properties of the trigger event. You can learn more about this in the workflow builder documentation.
Test the workflow
CheckpointConfirm you can trigger the workflowBefore publishing the workflow, you can test it to confirm it works as expected. On the right side of the workflow builder, you can see the Test button.
When you click the Test button, you will be directed to test the workflow by creating a mock trigger. The following options are available:
- Make a real request to PostHog: When enabled, real messages will be delivered to the recipient. When disabled, API calls are mocked and logged.
- Test event: Click to expand the test event configuration. An example event will be generated by default. You can click the Load new event to load a real event's data into the test event.
You can click the Run test button to send the test event.
- 4
Enable the workflow
RequiredOnce you have confirmed the workflow works as expected, you can enable it by clicking the Enable button at the top right of the workflow builder.
This will publish the workflow and start delivering messages to your when the trigger event is triggered. For this example workflow, you can hardcode all emails to your own email address for testing.
Monitor the workflow
CheckpointConfirm messages are being deliveredOnce the workflow is enabled, you can monitor your workflow in the Metrics and Logs tabs of the workflow builder.
To confirm your workflow is delivering messages, look for these signs:
- In the Metrics tab, you should see a line chart showing the number of succeeded and triggered messages.
- In the Logs tab, you can see logs of recently triggered workflows. Confirm that there aren't any errors.
- See the message delivered in your inbox.
Troubleshooting
CheckpointCommon issues you may encounterIssue Solution Emails not sending? Check that your domain is verified and you've added the DNS records correctly. Spam folder issues? Ensure SPF/DKIM are valid, and consider setting up DMARC. Variables not populating? Confirm the property exists on the person profile (e.g. person.name
).