Adding SMS automation

This commit is contained in:
2026-09-13 19:11:47 +03:30
parent bd63d2ab76
commit 45b0d46cfe
26 changed files with 1724 additions and 31 deletions
+6 -1
View File
@@ -1,11 +1,16 @@
import { Module, forwardRef } from '@nestjs/common';
import { NotificationsModule } from '../notifications/notifications.module';
import { AutomationsModule } from '../automations/automations.module';
import { MessageAutomationsModule } from '../message-automations/message-automations.module';
import { TicketsController } from './tickets.controller';
import { TicketsService } from './tickets.service';
@Module({
imports: [NotificationsModule, forwardRef(() => AutomationsModule)],
imports: [
NotificationsModule,
forwardRef(() => AutomationsModule),
MessageAutomationsModule,
],
controllers: [TicketsController],
providers: [TicketsService],
exports: [TicketsService],
+12 -6
View File
@@ -21,6 +21,7 @@ import {
} from '../common/record-scope';
import { NotificationsService } from '../notifications/notifications.service';
import { AutomationsService } from '../automations/automations.service';
import { MessageAutomationsService } from '../message-automations/message-automations.service';
const include = {
person: { select: { id: true, firstName: true, lastName: true } },
@@ -42,6 +43,7 @@ export class TicketsService {
private readonly prisma: PrismaService,
private readonly notifications: NotificationsService,
private readonly automations: AutomationsService,
private readonly messageAutomations: MessageAutomationsService,
) {}
async list(
@@ -228,9 +230,9 @@ export class TicketsService {
});
}
await this.automations.runTrigger('ticket_created', {
const createdCtx = {
organizationId: actor.organizationId,
entityType: 'ticket',
entityType: 'ticket' as const,
entityId: row.id,
title: row.subject,
personId: row.personId,
@@ -238,7 +240,9 @@ export class TicketsService {
dealId: row.dealId,
assigneeId: row.assigneeId,
ownerId: row.assigneeId,
});
};
await this.automations.runTrigger('ticket_created', createdCtx);
await this.messageAutomations.onEvent('ticket_created', createdCtx);
return this.toDto(row);
}
@@ -345,9 +349,9 @@ export class TicketsService {
existing.status !== 'resolved' &&
existing.status !== 'closed';
if (becameResolved) {
await this.automations.runTrigger('ticket_resolved', {
const resolvedCtx = {
organizationId: actor.organizationId,
entityType: 'ticket',
entityType: 'ticket' as const,
entityId: existing.id,
title: existing.subject,
personId: existing.personId,
@@ -355,7 +359,9 @@ export class TicketsService {
dealId: existing.dealId,
assigneeId: existing.assigneeId,
ownerId: existing.assigneeId,
});
};
await this.automations.runTrigger('ticket_resolved', resolvedCtx);
await this.messageAutomations.onEvent('ticket_resolved', resolvedCtx);
}
return this.get(actor, id);