The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
---
title: Closed Won Automations
description: Automate post-win activities when opportunities close.
---
import { PageBanner } from "/snippets/page-banner.mdx"
## The Problem
When an opportunity moves to "Closed Won":
- Company type needs to change from "Prospect" to "Customer"
- Onboarding tasks need to be created
- Customer success team needs to be notified
- Sales rep needs confirmation
Doing this manually is time-consuming and error-prone.
## The Solution
Create a workflow that handles all post-win activities automatically.
## Complete Workflow Setup
### Step 1: Create the Workflow
1. Go to **Settings β Workflows**
2. Click **+ New Workflow**
3. Name it "Deal Won - Post-Win Automation"
### Step 2: Configure the Trigger
1. Select **Record is Updated**
2. Choose **Opportunities**
3. Under "Fields to monitor", select **Stage**
### Step 3: Add Stage Filter
1. Add **Filter** action
2. Condition: `{{trigger.properties.after.stage}}` equals "Closed Won"
### Step 4: Update Company Type
1. Add **Update Record** action
2. Configure:
| Field | Value |
|-------|-------|
| **Object** | Companies |
| **Record** | `{{trigger.properties.after.companyId}}` |
| **Type** | Customer |
| **First Deal Date** | `{{trigger.properties.after.closeDate}}` |
| **Account Owner** | `{{trigger.properties.after.ownerId}}` |
Name this step "Update Company". Its output is the updated company, so later steps can insert its fields from the variable picker, shown below as `{{Update Company.name}}`. Pick them from the picker rather than typing them: variables point to the step's ID, not its name.
### Step 5: Create Onboarding Task
1. Add **Create Record** action
2. Configure:
| Field | Value |
|-------|-------|
| **Object** | Tasks |
| **Title** | `Onboarding: {{trigger.properties.after.name}}` |
| **Assignee** | Customer Success team member |
| **Due Date** | 3 days from now |
| **Priority** | High |
| **Related Company** | `{{trigger.properties.after.companyId}}` |
| **Related Opportunity** | `{{trigger.properties.after.id}}` |
| **Description** | `New customer onboarding for {{Update Company.name}}.` |
### Step 6: Notify Customer Success
1. Add **Send Email** action
2. Configure:
| Field | Value |
|-------|-------|
| **To** | [email protected] |
| **Subject** | `π New Customer: {{Update Company.name}}` |
| **Body** | See example below |
**Email body example**:
```
Hi CS Team,
We have a new customer!
Company: {{Update Company.name}}
Deal: {{trigger.properties.after.name}}
Close Date: {{trigger.properties.after.closeDate}}
An onboarding task has been created automatically.
Let's give them a great start!
```
### Step 7: Confirm to Sales Rep
1. Add a **Search Records** action named "Find Owner" to get the sales rep:
| Field | Value |
|-------|-------|
| **Object** | Workspace Members |
| **Filter** | ID equals `{{trigger.properties.after.ownerId}}` |
2. Add another **Send Email** action
3. Configure:
| Field | Value |
|-------|-------|
| **To** | `{{Find Owner.first.userEmail}}` |
| **Subject** | `β
Deal Closed: {{trigger.properties.after.name}}` |
| **Body** | Congratulations! Your deal has been processed. The customer success team has been notified and onboarding has begun. |
Select the **To** value from the variable picker under the "Find Owner" step.
### Step 8: Test and Activate
1. Test by moving a test opportunity to "Closed Won"
2. Verify:
- Company type changed to "Customer"
- Onboarding task created
- CS team received email
- Sales rep received confirmation
3. Activate when ready
## Handling Closed Lost
Create a similar workflow for lost deals:
### Trigger
- Record is Updated (Opportunities, Stage = "Closed Lost")
### Actions
1. **Create Record**: Task for "Lost Deal Analysis"
2. **Update Record**: Add lost reason to company record
3. **Send Email**: Notify manager of lost deal
## Advanced: Multi-Step Onboarding
For complex onboarding, create multiple tasks:
```javascript
export const main = async (params) => {
const tasks = [
{ title: "Welcome call", daysFromNow: 1, assignee: "CS" },
{ title: "Send onboarding materials", daysFromNow: 2, assignee: "CS" },
{ title: "Technical setup", daysFromNow: 5, assignee: "Support" },
{ title: "30-day check-in", daysFromNow: 30, assignee: "CS" }
];
return { tasks };
};
```
Use **Iterator** to create each task from the array.
## Customization Ideas
### Keep your other tools up-to-date
- Create customer in billing system with an **HTTP Request**
### Conditional actions
Use **Filter** actions to:
- Different onboarding for enterprise vs SMB
- Different assignees based on region
- Skip notifications for small deals
### Include Deal details
Use **Code** action to format:
- Deal summary documents
- Handoff notes for CS team
- Custom onboarding checklists
## Related
- [Workflow Actions](/user-guide/workflows/capabilities/workflow-actions)
- [Send Emails from Workflows](/user-guide/workflows/capabilities/send-emails-from-workflows)
<PageBanner illustration="card-page-campaign-practices" />