Let automations fire on more CRM events and open the studio from the main nav.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -147,6 +147,17 @@ export class DealsService {
|
||||
include: dealInclude,
|
||||
});
|
||||
|
||||
await this.automations.runTrigger('deal_created', {
|
||||
organizationId,
|
||||
entityType: 'deal',
|
||||
entityId: created.id,
|
||||
title: created.title,
|
||||
personId: created.personId,
|
||||
companyId: created.companyId,
|
||||
dealId: created.id,
|
||||
ownerId: created.ownerId,
|
||||
});
|
||||
|
||||
return this.pipelines.toDealDto(created);
|
||||
}
|
||||
|
||||
@@ -290,17 +301,24 @@ export class DealsService {
|
||||
});
|
||||
}
|
||||
|
||||
if (status === 'won' && deal.status !== 'won') {
|
||||
await this.automations.runTrigger('deal_won', {
|
||||
if (deal.stageId !== stage.id) {
|
||||
const ctx = {
|
||||
organizationId,
|
||||
entityType: 'deal',
|
||||
entityType: 'deal' as const,
|
||||
entityId: deal.id,
|
||||
title: deal.title,
|
||||
personId: deal.personId,
|
||||
companyId: deal.companyId,
|
||||
dealId: deal.id,
|
||||
ownerId: deal.ownerId,
|
||||
});
|
||||
};
|
||||
await this.automations.runTrigger('deal_stage_changed', ctx);
|
||||
if (status === 'won' && deal.status !== 'won') {
|
||||
await this.automations.runTrigger('deal_won', ctx);
|
||||
}
|
||||
if (status === 'lost' && deal.status !== 'lost') {
|
||||
await this.automations.runTrigger('deal_lost', ctx);
|
||||
}
|
||||
}
|
||||
|
||||
return this.pipelines.toDealDto(row);
|
||||
|
||||
Reference in New Issue
Block a user