Examples
Auth Provider Webhook
This example demonstrates an authentication provider webhook process using Upstash Workflow. The workflow handles the user creation, trial management, email reminders and notifications.
Use Case
Our workflow will:
- Receive a webhook event from an authentication provider (e.g. Firebase, Auth0, Clerk etc.)
- Create a new user in our database
- Create a new user in Stripe
- Start a trial in Stripe
- Send a welcome email
- Send a reminder email if the user hasn’t solved any questions in the last 7 days
- Send a trial warning email if the user hasn’t upgraded 2 days before the trial ends
- Send a trial ended email if the user hasn’t upgraded
Code Example
Code Breakdown
1. Sync User
We start by creating a new user in our database:
2. Create New User in Stripe
Next, we create a new user in Stripe:
3. Start Trial in Stripe
We start a trial in Stripe:
4. Send Welcome Email
We send a welcome email to the user:
5. Send Reminder Email
After 7 days, we check if the user has solved any questions. If not, we send a reminder email:
The sendProblemSolvedEmail
method:
6. Send Trial Warning Email
If the user hasn’t upgraded 2 days before the trial ends, we send a trial warning email:
If they upgraded, we end the workflow by returning.
7. Send Trial Ended Email
If the user hasn’t upgraded after the trial ends, we send a trial ended email:
Was this page helpful?