@in.pulse-crm/sdk 2.14.8 → 2.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai.client.d.ts +33 -0
- package/dist/ai.client.js +120 -0
- package/dist/customers.client.d.ts +16 -2
- package/dist/customers.client.js +34 -0
- package/dist/files.client.d.ts +0 -1
- package/dist/files.client.js +0 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/types/ai.types.d.ts +318 -0
- package/dist/types/ai.types.js +2 -0
- package/dist/types/customers.types.d.ts +186 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/response.types.d.ts +8 -0
- package/dist/types/socket-events.types.d.ts +15 -2
- package/dist/types/socket-events.types.js +1 -0
- package/dist/types/whatsapp.types.d.ts +169 -0
- package/dist/whatsapp.client.d.ts +7 -1
- package/dist/whatsapp.client.js +49 -0
- package/package.json +4 -2
- package/src/ai.client.ts +285 -0
- package/src/customers.client.ts +70 -1
- package/src/files.client.ts +0 -7
- package/src/index.ts +1 -0
- package/src/types/ai.types.ts +378 -0
- package/src/types/customers.types.ts +180 -0
- package/src/types/index.ts +1 -0
- package/src/types/response.types.ts +9 -0
- package/src/types/socket-events.types.ts +22 -0
- package/src/types/whatsapp.types.ts +219 -0
- package/src/whatsapp.client.ts +79 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import ApiClient from "./api-client";
|
|
2
|
+
import type { AiAgentConfig, AiTenantConfig, AnalyzeCustomerRequest, AnalyzeCustomerResponse, CreateSupervisorAiSessionRequest, SuggestResponseRequest, SuggestResponseResponse, SupervisorAiSession, SupervisorAiSessionDetail, SummarizeChatRequest, SummarizeChatResponse, AiAgent, AiAgentChatSession, CreateAiAgentInput, UpdateAiAgentInput, AiAgentAudienceInput, AiAgentKnowledgeEntryInput, AiAgentActionLogFilters, PaginatedActionLogs, AiAgentAudiencePreview, SendSupervisorAiMessageRequest, SendSupervisorAiMessageResponse, AiUsageSummary } from "./types/ai.types";
|
|
3
|
+
export default class AiClient extends ApiClient {
|
|
4
|
+
private authHeader;
|
|
5
|
+
suggestResponse(data: SuggestResponseRequest, token: string): Promise<SuggestResponseResponse>;
|
|
6
|
+
summarizeChat(data: SummarizeChatRequest, token: string): Promise<SummarizeChatResponse>;
|
|
7
|
+
analyzeCustomer(data: AnalyzeCustomerRequest, token: string): Promise<AnalyzeCustomerResponse>;
|
|
8
|
+
listSupervisorSessions(token: string, status?: "ACTIVE" | "ARCHIVED"): Promise<SupervisorAiSession[]>;
|
|
9
|
+
createSupervisorSession(data: CreateSupervisorAiSessionRequest | undefined, token: string): Promise<SupervisorAiSession>;
|
|
10
|
+
patchSupervisorSessionStatus(sessionId: number, status: "ACTIVE" | "ARCHIVED", token: string): Promise<SupervisorAiSession>;
|
|
11
|
+
getSupervisorSession(sessionId: number, token: string): Promise<SupervisorAiSessionDetail>;
|
|
12
|
+
sendSupervisorMessage(sessionId: number, data: SendSupervisorAiMessageRequest, token: string): Promise<SendSupervisorAiMessageResponse>;
|
|
13
|
+
getTenantConfig(instance: string, token: string): Promise<AiTenantConfig>;
|
|
14
|
+
upsertTenantConfig(instance: string, data: Partial<AiTenantConfig>, token: string): Promise<AiTenantConfig>;
|
|
15
|
+
getAgentConfig(instance: string, token: string): Promise<AiAgentConfig | null>;
|
|
16
|
+
upsertAgentConfig(instance: string, data: Partial<AiAgentConfig>, token: string): Promise<AiAgentConfig>;
|
|
17
|
+
listAgents(token: string): Promise<AiAgent[]>;
|
|
18
|
+
getAgent(agentId: number, token: string): Promise<AiAgent>;
|
|
19
|
+
createAgent(data: CreateAiAgentInput, token: string): Promise<AiAgent>;
|
|
20
|
+
updateAgent(agentId: number, data: UpdateAiAgentInput, token: string): Promise<AiAgent>;
|
|
21
|
+
deleteAgent(agentId: number, token: string): Promise<void>;
|
|
22
|
+
upsertAgentAudience(agentId: number, data: AiAgentAudienceInput, token: string): Promise<AiAgent>;
|
|
23
|
+
previewAgentAudience(agentId: number, filters: {
|
|
24
|
+
page?: number;
|
|
25
|
+
perPage?: number;
|
|
26
|
+
} | undefined, token: string): Promise<AiAgentAudiencePreview>;
|
|
27
|
+
addAgentKnowledgeEntry(agentId: number, data: AiAgentKnowledgeEntryInput, token: string): Promise<AiAgent>;
|
|
28
|
+
updateAgentKnowledgeEntry(agentId: number, entryId: number, data: Partial<AiAgentKnowledgeEntryInput>, token: string): Promise<AiAgent>;
|
|
29
|
+
deleteAgentKnowledgeEntry(agentId: number, entryId: number, token: string): Promise<void>;
|
|
30
|
+
listAgentActionLogs(filters: AiAgentActionLogFilters, token: string): Promise<PaginatedActionLogs>;
|
|
31
|
+
listActiveSessions(token: string): Promise<AiAgentChatSession[]>;
|
|
32
|
+
getUsageSummary(period: string, token: string): Promise<AiUsageSummary>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const api_client_1 = __importDefault(require("./api-client"));
|
|
7
|
+
class AiClient extends api_client_1.default {
|
|
8
|
+
authHeader(token) {
|
|
9
|
+
return { Authorization: `Bearer ${token}` };
|
|
10
|
+
}
|
|
11
|
+
async suggestResponse(data, token) {
|
|
12
|
+
const { data: res } = await this.ax.post("/api/ai/completions/suggest-response", data, { headers: this.authHeader(token) });
|
|
13
|
+
return res.data;
|
|
14
|
+
}
|
|
15
|
+
async summarizeChat(data, token) {
|
|
16
|
+
const { data: res } = await this.ax.post("/api/ai/completions/summarize-chat", data, { headers: this.authHeader(token) });
|
|
17
|
+
return res.data;
|
|
18
|
+
}
|
|
19
|
+
async analyzeCustomer(data, token) {
|
|
20
|
+
const { data: res } = await this.ax.post("/api/ai/completions/analyze-customer", data, { headers: this.authHeader(token) });
|
|
21
|
+
return res.data;
|
|
22
|
+
}
|
|
23
|
+
async listSupervisorSessions(token, status) {
|
|
24
|
+
const query = status ? `?status=${status}` : "";
|
|
25
|
+
const { data: res } = await this.ax.get(`/api/ai/supervisor-chat/sessions${query}`, { headers: this.authHeader(token) });
|
|
26
|
+
return res.data;
|
|
27
|
+
}
|
|
28
|
+
async createSupervisorSession(data, token) {
|
|
29
|
+
const { data: res } = await this.ax.post("/api/ai/supervisor-chat/sessions", data, { headers: this.authHeader(token) });
|
|
30
|
+
return res.data;
|
|
31
|
+
}
|
|
32
|
+
async patchSupervisorSessionStatus(sessionId, status, token) {
|
|
33
|
+
const { data: res } = await this.ax.patch(`/api/ai/supervisor-chat/sessions/${sessionId}`, { status }, { headers: this.authHeader(token) });
|
|
34
|
+
return res.data;
|
|
35
|
+
}
|
|
36
|
+
async getSupervisorSession(sessionId, token) {
|
|
37
|
+
const { data: res } = await this.ax.get(`/api/ai/supervisor-chat/sessions/${sessionId}`, { headers: this.authHeader(token) });
|
|
38
|
+
return res.data;
|
|
39
|
+
}
|
|
40
|
+
async sendSupervisorMessage(sessionId, data, token) {
|
|
41
|
+
const { data: res } = await this.ax.post(`/api/ai/supervisor-chat/sessions/${sessionId}/messages`, data, { headers: this.authHeader(token) });
|
|
42
|
+
return res.data;
|
|
43
|
+
}
|
|
44
|
+
async getTenantConfig(instance, token) {
|
|
45
|
+
const { data: res } = await this.ax.get(`/api/ai/tenant-config/${instance}`, { headers: this.authHeader(token) });
|
|
46
|
+
return res.data;
|
|
47
|
+
}
|
|
48
|
+
async upsertTenantConfig(instance, data, token) {
|
|
49
|
+
const { data: res } = await this.ax.put(`/api/ai/tenant-config/${instance}`, data, { headers: this.authHeader(token) });
|
|
50
|
+
return res.data;
|
|
51
|
+
}
|
|
52
|
+
async getAgentConfig(instance, token) {
|
|
53
|
+
const { data: res } = await this.ax.get(`/api/ai/agent-config/${instance}`, { headers: this.authHeader(token) });
|
|
54
|
+
return res.data;
|
|
55
|
+
}
|
|
56
|
+
async upsertAgentConfig(instance, data, token) {
|
|
57
|
+
const { data: res } = await this.ax.put(`/api/ai/agent-config/${instance}`, data, { headers: this.authHeader(token) });
|
|
58
|
+
return res.data;
|
|
59
|
+
}
|
|
60
|
+
// ─── AI Agents CRUD ───────────────────────────────────────────────────────
|
|
61
|
+
async listAgents(token) {
|
|
62
|
+
const { data: res } = await this.ax.get("/api/ai/agents", { headers: this.authHeader(token) });
|
|
63
|
+
return res.data;
|
|
64
|
+
}
|
|
65
|
+
async getAgent(agentId, token) {
|
|
66
|
+
const { data: res } = await this.ax.get(`/api/ai/agents/${agentId}`, { headers: this.authHeader(token) });
|
|
67
|
+
return res.data;
|
|
68
|
+
}
|
|
69
|
+
async createAgent(data, token) {
|
|
70
|
+
const { data: res } = await this.ax.post("/api/ai/agents", data, { headers: this.authHeader(token) });
|
|
71
|
+
return res.data;
|
|
72
|
+
}
|
|
73
|
+
async updateAgent(agentId, data, token) {
|
|
74
|
+
const { data: res } = await this.ax.patch(`/api/ai/agents/${agentId}`, data, { headers: this.authHeader(token) });
|
|
75
|
+
return res.data;
|
|
76
|
+
}
|
|
77
|
+
async deleteAgent(agentId, token) {
|
|
78
|
+
await this.ax.delete(`/api/ai/agents/${agentId}`, { headers: this.authHeader(token) });
|
|
79
|
+
}
|
|
80
|
+
async upsertAgentAudience(agentId, data, token) {
|
|
81
|
+
const { data: res } = await this.ax.put(`/api/ai/agents/${agentId}/audience`, data, { headers: this.authHeader(token) });
|
|
82
|
+
return res.data;
|
|
83
|
+
}
|
|
84
|
+
async previewAgentAudience(agentId, filters, token) {
|
|
85
|
+
const { data: res } = await this.ax.post(`/api/ai/agents/${agentId}/audience/preview`, undefined, {
|
|
86
|
+
params: filters,
|
|
87
|
+
headers: this.authHeader(token),
|
|
88
|
+
});
|
|
89
|
+
return { data: res.data, page: res.page };
|
|
90
|
+
}
|
|
91
|
+
async addAgentKnowledgeEntry(agentId, data, token) {
|
|
92
|
+
const { data: res } = await this.ax.post(`/api/ai/agents/${agentId}/knowledge`, data, { headers: this.authHeader(token) });
|
|
93
|
+
return res.data;
|
|
94
|
+
}
|
|
95
|
+
async updateAgentKnowledgeEntry(agentId, entryId, data, token) {
|
|
96
|
+
const { data: res } = await this.ax.patch(`/api/ai/agents/${agentId}/knowledge/${entryId}`, data, { headers: this.authHeader(token) });
|
|
97
|
+
return res.data;
|
|
98
|
+
}
|
|
99
|
+
async deleteAgentKnowledgeEntry(agentId, entryId, token) {
|
|
100
|
+
await this.ax.delete(`/api/ai/agents/${agentId}/knowledge/${entryId}`, {
|
|
101
|
+
headers: this.authHeader(token),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async listAgentActionLogs(filters, token) {
|
|
105
|
+
const { data: res } = await this.ax.get("/api/ai/agents/logs", {
|
|
106
|
+
params: filters,
|
|
107
|
+
headers: this.authHeader(token),
|
|
108
|
+
});
|
|
109
|
+
return res.data;
|
|
110
|
+
}
|
|
111
|
+
async listActiveSessions(token) {
|
|
112
|
+
const { data: res } = await this.ax.get("/api/ai/agents/sessions/active", { headers: this.authHeader(token) });
|
|
113
|
+
return res.data;
|
|
114
|
+
}
|
|
115
|
+
async getUsageSummary(period, token) {
|
|
116
|
+
const { data: res } = await this.ax.get(`/api/ai/usage?period=${encodeURIComponent(period)}`, { headers: this.authHeader(token) });
|
|
117
|
+
return res.data;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.default = AiClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ApiClient from "./api-client";
|
|
2
|
-
import { PaginatedResponse, RequestFilters } from "./types";
|
|
3
|
-
import { CreateCustomerDTO, Customer, UpdateCustomerDTO } from "./types/customers.types";
|
|
2
|
+
import { MessageResponse, PaginatedResponse, RequestFilters } from "./types";
|
|
3
|
+
import { CreateCustomerDTO, Customer, CustomerFullDetail, CustomerLookupOption, FinishTelephonyScheduleDTO, CustomerTelephonySchedule, UpdateCustomerDTO } from "./types/customers.types";
|
|
4
4
|
declare class CustomersClient extends ApiClient {
|
|
5
5
|
/**
|
|
6
6
|
* Cria um novo cliente.
|
|
@@ -14,6 +14,15 @@ declare class CustomersClient extends ApiClient {
|
|
|
14
14
|
* @returns Uma Promise que resolve para o cliente obtido.
|
|
15
15
|
*/
|
|
16
16
|
getCustomerById(customerId: number): Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Obtém os detalhes completos do cliente para o modal CRM.
|
|
19
|
+
* @param customerId - O ID do cliente a ser obtido.
|
|
20
|
+
* @returns Uma Promise que resolve para os detalhes agregados do cliente.
|
|
21
|
+
*/
|
|
22
|
+
getCustomerFullDetail(customerId: number): Promise<{
|
|
23
|
+
message: string;
|
|
24
|
+
data: CustomerFullDetail;
|
|
25
|
+
}>;
|
|
17
26
|
/**
|
|
18
27
|
* Atualiza um cliente existente.
|
|
19
28
|
* @param customerId - O ID do cliente a ser atualizado.
|
|
@@ -29,6 +38,11 @@ declare class CustomersClient extends ApiClient {
|
|
|
29
38
|
* @returns Uma Promise que resolve para uma lista de clientes.
|
|
30
39
|
*/
|
|
31
40
|
getCustomers(filters?: RequestFilters<Customer>): Promise<PaginatedResponse<Customer>>;
|
|
41
|
+
getCampaigns(): Promise<CustomerLookupOption[]>;
|
|
42
|
+
getSegments(): Promise<CustomerLookupOption[]>;
|
|
43
|
+
getOperators(): Promise<CustomerLookupOption[]>;
|
|
44
|
+
getTelephonySchedules(filters?: RequestFilters<CustomerTelephonySchedule>): Promise<PaginatedResponse<CustomerTelephonySchedule>>;
|
|
45
|
+
finishTelephonySchedule(scheduleId: number, data: FinishTelephonyScheduleDTO): Promise<MessageResponse>;
|
|
32
46
|
/**
|
|
33
47
|
* Define o token de autenticação para as requisições.
|
|
34
48
|
* @param token - O token de autenticação a ser definido.
|
package/dist/customers.client.js
CHANGED
|
@@ -23,6 +23,15 @@ class CustomersClient extends api_client_1.default {
|
|
|
23
23
|
const response = await this.ax.get(`/api/customers/${customerId}`);
|
|
24
24
|
return response.data;
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Obtém os detalhes completos do cliente para o modal CRM.
|
|
28
|
+
* @param customerId - O ID do cliente a ser obtido.
|
|
29
|
+
* @returns Uma Promise que resolve para os detalhes agregados do cliente.
|
|
30
|
+
*/
|
|
31
|
+
async getCustomerFullDetail(customerId) {
|
|
32
|
+
const response = await this.ax.get(`/api/customers/${customerId}/full`);
|
|
33
|
+
return response.data;
|
|
34
|
+
}
|
|
26
35
|
/**
|
|
27
36
|
* Atualiza um cliente existente.
|
|
28
37
|
* @param customerId - O ID do cliente a ser atualizado.
|
|
@@ -49,6 +58,31 @@ class CustomersClient extends api_client_1.default {
|
|
|
49
58
|
const response = await this.ax.get(baseUrl);
|
|
50
59
|
return response.data;
|
|
51
60
|
}
|
|
61
|
+
async getCampaigns() {
|
|
62
|
+
const response = await this.ax.get(`/api/customers/campaigns`);
|
|
63
|
+
return response.data.data;
|
|
64
|
+
}
|
|
65
|
+
async getSegments() {
|
|
66
|
+
const response = await this.ax.get(`/api/customers/segments`);
|
|
67
|
+
return response.data.data;
|
|
68
|
+
}
|
|
69
|
+
async getOperators() {
|
|
70
|
+
const response = await this.ax.get(`/api/customers/operators`);
|
|
71
|
+
return response.data.data;
|
|
72
|
+
}
|
|
73
|
+
async getTelephonySchedules(filters) {
|
|
74
|
+
let baseUrl = `/api/customers/schedules/telephony`;
|
|
75
|
+
if (filters) {
|
|
76
|
+
const params = new URLSearchParams(filters);
|
|
77
|
+
baseUrl += `?${params.toString()}`;
|
|
78
|
+
}
|
|
79
|
+
const response = await this.ax.get(baseUrl);
|
|
80
|
+
return response.data;
|
|
81
|
+
}
|
|
82
|
+
async finishTelephonySchedule(scheduleId, data) {
|
|
83
|
+
const response = await this.ax.patch(`/api/customers/schedules/telephony/${scheduleId}/finish`, data);
|
|
84
|
+
return response.data;
|
|
85
|
+
}
|
|
52
86
|
/**
|
|
53
87
|
* Define o token de autenticação para as requisições.
|
|
54
88
|
* @param token - O token de autenticação a ser definido.
|
package/dist/files.client.d.ts
CHANGED
package/dist/files.client.js
CHANGED
|
@@ -73,10 +73,5 @@ class FilesClient extends api_client_1.default {
|
|
|
73
73
|
const response = await this.ax.post(`/api/waba`, { instance, wabaMediaId });
|
|
74
74
|
return response.data.data;
|
|
75
75
|
}
|
|
76
|
-
async getWabaMedia(fileId) {
|
|
77
|
-
const response = await this.ax.post(`/api/waba/get-media-id`, { fileId });
|
|
78
|
-
const mediaId = response.data.data.mediaId;
|
|
79
|
-
return mediaId;
|
|
80
|
-
}
|
|
81
76
|
}
|
|
82
77
|
exports.default = FilesClient;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -17,8 +17,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.ReadyMessageClient = exports.InternalChatClient = exports.WalletsClient = exports.WhatsappClient = exports.UsersClient = exports.SocketClient = exports.SocketServerClient = exports.ReportsClient = exports.InstancesClient = exports.FilesClient = exports.CustomersClient = exports.AuthClient = void 0;
|
|
20
|
+
exports.ReadyMessageClient = exports.InternalChatClient = exports.WalletsClient = exports.WhatsappClient = exports.UsersClient = exports.SocketClient = exports.SocketServerClient = exports.ReportsClient = exports.InstancesClient = exports.FilesClient = exports.CustomersClient = exports.AuthClient = exports.AiClient = void 0;
|
|
21
21
|
__exportStar(require("./types"), exports);
|
|
22
|
+
var ai_client_1 = require("./ai.client");
|
|
23
|
+
Object.defineProperty(exports, "AiClient", { enumerable: true, get: function () { return __importDefault(ai_client_1).default; } });
|
|
22
24
|
var auth_client_1 = require("./auth.client");
|
|
23
25
|
Object.defineProperty(exports, "AuthClient", { enumerable: true, get: function () { return __importDefault(auth_client_1).default; } });
|
|
24
26
|
var customers_client_1 = require("./customers.client");
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import type { CustomerAgeLevel, CustomerInteractionLevel, CustomerProfileSummaryLevel, CustomerPurchaseInterestLevel, CustomerPurchaseLevel, WppContactWithCustomer } from "./whatsapp.types";
|
|
2
|
+
export interface SuggestResponseRequest {
|
|
3
|
+
chatId: number;
|
|
4
|
+
}
|
|
5
|
+
export interface SuggestResponseResponse {
|
|
6
|
+
suggestions: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface SummarizeChatRequest {
|
|
9
|
+
chatId: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SummarizeChatResponse {
|
|
12
|
+
summary: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AnalyzeCustomerRequest {
|
|
15
|
+
customerId: number;
|
|
16
|
+
}
|
|
17
|
+
export interface AnalyzeCustomerResponse {
|
|
18
|
+
analysis: string;
|
|
19
|
+
}
|
|
20
|
+
export type SupervisorAiSessionStatus = "ACTIVE" | "ARCHIVED";
|
|
21
|
+
export type SupervisorAiMessageRole = "USER" | "ASSISTANT";
|
|
22
|
+
export type SupervisorAiReportFormat = "csv" | "pdf" | "txt";
|
|
23
|
+
export interface SupervisorAiContextInput {
|
|
24
|
+
chatId?: number;
|
|
25
|
+
customerId?: number;
|
|
26
|
+
dateFrom?: string;
|
|
27
|
+
dateTo?: string;
|
|
28
|
+
operatorIds?: number[];
|
|
29
|
+
sectorIds?: number[];
|
|
30
|
+
includeMetrics?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface SupervisorAiSource {
|
|
33
|
+
type: "action" | "chat" | "contact" | "customer" | "metrics" | "session" | "sql";
|
|
34
|
+
label: string;
|
|
35
|
+
entityId?: number;
|
|
36
|
+
metadata?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface SupervisorAiReportPreview {
|
|
39
|
+
title: string;
|
|
40
|
+
summary: string;
|
|
41
|
+
columns: string[];
|
|
42
|
+
rows: Array<Record<string, string | number | boolean | null>>;
|
|
43
|
+
availableFormats: SupervisorAiReportFormat[];
|
|
44
|
+
}
|
|
45
|
+
export interface SupervisorAiMessageMetadata {
|
|
46
|
+
context?: SupervisorAiContextInput;
|
|
47
|
+
sources?: SupervisorAiSource[];
|
|
48
|
+
reportPreview?: SupervisorAiReportPreview | null;
|
|
49
|
+
}
|
|
50
|
+
export interface SupervisorAiSession {
|
|
51
|
+
id: number;
|
|
52
|
+
instance: string;
|
|
53
|
+
userId: number;
|
|
54
|
+
title: string;
|
|
55
|
+
status: SupervisorAiSessionStatus;
|
|
56
|
+
createdAt: string;
|
|
57
|
+
updatedAt: string;
|
|
58
|
+
lastMessageAt: string | null;
|
|
59
|
+
}
|
|
60
|
+
export interface SupervisorAiMessage {
|
|
61
|
+
id: number;
|
|
62
|
+
sessionId: number;
|
|
63
|
+
role: SupervisorAiMessageRole;
|
|
64
|
+
content: string;
|
|
65
|
+
metadata: SupervisorAiMessageMetadata | null;
|
|
66
|
+
createdAt: string;
|
|
67
|
+
}
|
|
68
|
+
export interface CreateSupervisorAiSessionRequest {
|
|
69
|
+
title?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface SupervisorAiFileContext {
|
|
72
|
+
name: string;
|
|
73
|
+
content: string;
|
|
74
|
+
}
|
|
75
|
+
export interface SendSupervisorAiMessageRequest {
|
|
76
|
+
message: string;
|
|
77
|
+
context?: SupervisorAiContextInput;
|
|
78
|
+
model?: string;
|
|
79
|
+
fileContext?: SupervisorAiFileContext[];
|
|
80
|
+
}
|
|
81
|
+
export interface SendSupervisorAiMessageResponse {
|
|
82
|
+
session: SupervisorAiSession;
|
|
83
|
+
userMessage: SupervisorAiMessage;
|
|
84
|
+
assistantMessage: SupervisorAiMessage;
|
|
85
|
+
sources: SupervisorAiSource[];
|
|
86
|
+
reportPreview: SupervisorAiReportPreview | null;
|
|
87
|
+
}
|
|
88
|
+
export interface SupervisorAiSessionDetail {
|
|
89
|
+
session: SupervisorAiSession;
|
|
90
|
+
messages: SupervisorAiMessage[];
|
|
91
|
+
}
|
|
92
|
+
export interface AiFeatureModels {
|
|
93
|
+
suggest_response?: string;
|
|
94
|
+
summarize_chat?: string;
|
|
95
|
+
analyze_customer?: string;
|
|
96
|
+
supervisor_chat?: string;
|
|
97
|
+
}
|
|
98
|
+
export interface AiTenantConfig {
|
|
99
|
+
instance: string;
|
|
100
|
+
model: string;
|
|
101
|
+
temperature: number;
|
|
102
|
+
maxTokens: number;
|
|
103
|
+
enabled: boolean;
|
|
104
|
+
monthlyBudgetUsd?: number | null;
|
|
105
|
+
availableModels?: string[] | null;
|
|
106
|
+
featureModels?: AiFeatureModels | null;
|
|
107
|
+
operatorBudgets?: Record<string, number> | null;
|
|
108
|
+
}
|
|
109
|
+
export interface AiFeatureUsageStat {
|
|
110
|
+
feature: string;
|
|
111
|
+
callCount: number;
|
|
112
|
+
inputTokens: number;
|
|
113
|
+
outputTokens: number;
|
|
114
|
+
estimatedCostUsd: number;
|
|
115
|
+
}
|
|
116
|
+
export interface AiOperatorUsageStat {
|
|
117
|
+
operatorId: number;
|
|
118
|
+
callCount: number;
|
|
119
|
+
inputTokens: number;
|
|
120
|
+
outputTokens: number;
|
|
121
|
+
estimatedCostUsd: number;
|
|
122
|
+
}
|
|
123
|
+
export interface AiUsageSummary {
|
|
124
|
+
period: string;
|
|
125
|
+
totalInputTokens: number;
|
|
126
|
+
totalOutputTokens: number;
|
|
127
|
+
estimatedCostUsd: number;
|
|
128
|
+
byFeature: AiFeatureUsageStat[];
|
|
129
|
+
byOperator: AiOperatorUsageStat[];
|
|
130
|
+
}
|
|
131
|
+
export interface AiAgentConfig {
|
|
132
|
+
instance: string;
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
model: string;
|
|
135
|
+
systemPrompt: string;
|
|
136
|
+
maxMessagesPerChat: number;
|
|
137
|
+
conditions: unknown;
|
|
138
|
+
}
|
|
139
|
+
export type AiAgentTriggerType = "MESSAGE_DURING_HOURS" | "RESPONSE_TIMEOUT" | "KEYWORD" | "ALWAYS";
|
|
140
|
+
export type AiAgentProactiveFrequency = "DAILY" | "WEEKDAYS" | "CUSTOM_DAYS";
|
|
141
|
+
export type AiAgentProactiveEntryMessageMode = "AI_TEXT" | "WABA_TEMPLATE";
|
|
142
|
+
export type AiAgentActionType = "REPLY" | "SEND_TEMPLATE" | "SEND_FILE" | "ESCALATE" | "CLOSE_CHAT" | "UPDATE_CRM" | "SCHEDULE" | "IGNORED";
|
|
143
|
+
export type AiAgentChatSessionStatus = "ACTIVE" | "PAUSED" | "FINISHED";
|
|
144
|
+
export interface AiAgentTrigger {
|
|
145
|
+
id: number;
|
|
146
|
+
agentId: number;
|
|
147
|
+
type: AiAgentTriggerType;
|
|
148
|
+
config: Record<string, unknown>;
|
|
149
|
+
}
|
|
150
|
+
export interface AiAgentAudienceDefinition {
|
|
151
|
+
id: number;
|
|
152
|
+
agentId: number;
|
|
153
|
+
filtersJson: Record<string, unknown>;
|
|
154
|
+
manualIncludeJson: Record<string, unknown>;
|
|
155
|
+
manualExcludeJson: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
export interface AiAgentKnowledgeEntry {
|
|
158
|
+
id: number;
|
|
159
|
+
agentId: number;
|
|
160
|
+
title: string;
|
|
161
|
+
content: string;
|
|
162
|
+
fileId: number | null;
|
|
163
|
+
fileName: string | null;
|
|
164
|
+
fileType: string | null;
|
|
165
|
+
fileSize: number | null;
|
|
166
|
+
order: number;
|
|
167
|
+
}
|
|
168
|
+
export interface AiAgentProactiveSchedule {
|
|
169
|
+
frequency: AiAgentProactiveFrequency;
|
|
170
|
+
timezone: string;
|
|
171
|
+
startTime: string;
|
|
172
|
+
daysOfWeek: number[];
|
|
173
|
+
}
|
|
174
|
+
export interface AiAgentProactiveConfig {
|
|
175
|
+
enabled: boolean;
|
|
176
|
+
schedule: AiAgentProactiveSchedule;
|
|
177
|
+
batchSize: number;
|
|
178
|
+
entryMessageMode: AiAgentProactiveEntryMessageMode;
|
|
179
|
+
skipContactsWithOpenChat: boolean;
|
|
180
|
+
}
|
|
181
|
+
export interface AiAgent {
|
|
182
|
+
id: number;
|
|
183
|
+
instance: string;
|
|
184
|
+
name: string;
|
|
185
|
+
description: string | null;
|
|
186
|
+
enabled: boolean;
|
|
187
|
+
systemPrompt: string;
|
|
188
|
+
model: string;
|
|
189
|
+
temperature: number;
|
|
190
|
+
maxTokens: number;
|
|
191
|
+
maxTurnsPerChat: number;
|
|
192
|
+
cooldownSeconds: number;
|
|
193
|
+
allowedActions: AiAgentActionType[];
|
|
194
|
+
proactiveConfig: AiAgentProactiveConfig | null;
|
|
195
|
+
templateName: string | null;
|
|
196
|
+
templateLanguage: string | null;
|
|
197
|
+
templateVariableMapping: Record<string, string> | null;
|
|
198
|
+
escalateToWalletId: number | null;
|
|
199
|
+
escalateToUserId: number | null;
|
|
200
|
+
escalateToUserIds: number[];
|
|
201
|
+
createdAt: string;
|
|
202
|
+
updatedAt: string;
|
|
203
|
+
triggers: AiAgentTrigger[];
|
|
204
|
+
audience: AiAgentAudienceDefinition | null;
|
|
205
|
+
knowledgeEntries: AiAgentKnowledgeEntry[];
|
|
206
|
+
}
|
|
207
|
+
export interface AiAgentChatSession {
|
|
208
|
+
id: number;
|
|
209
|
+
agentId: number;
|
|
210
|
+
chatId: number;
|
|
211
|
+
instance: string;
|
|
212
|
+
status: AiAgentChatSessionStatus;
|
|
213
|
+
turnCount: number;
|
|
214
|
+
startedAt: string;
|
|
215
|
+
finishedAt: string | null;
|
|
216
|
+
lastRepliedAt: string | null;
|
|
217
|
+
}
|
|
218
|
+
export interface AiAgentActionLog {
|
|
219
|
+
id: number;
|
|
220
|
+
agentId: number;
|
|
221
|
+
sessionId: number | null;
|
|
222
|
+
chatId: number;
|
|
223
|
+
instance: string;
|
|
224
|
+
actionType: AiAgentActionType;
|
|
225
|
+
success: boolean;
|
|
226
|
+
errorMessage: string | null;
|
|
227
|
+
payload: Record<string, unknown> | null;
|
|
228
|
+
createdAt: string;
|
|
229
|
+
}
|
|
230
|
+
export interface AiAgentAudienceFilters {
|
|
231
|
+
profileLevel?: CustomerProfileSummaryLevel;
|
|
232
|
+
interactionLevel?: CustomerInteractionLevel;
|
|
233
|
+
purchaseLevel?: CustomerPurchaseLevel;
|
|
234
|
+
ageLevel?: CustomerAgeLevel;
|
|
235
|
+
purchaseInterestLevel?: CustomerPurchaseInterestLevel;
|
|
236
|
+
state?: string;
|
|
237
|
+
city?: string;
|
|
238
|
+
activeCustomer?: "SIM" | "NAO";
|
|
239
|
+
searchTerm?: string;
|
|
240
|
+
segmentIds?: number[];
|
|
241
|
+
campaignIds?: number[];
|
|
242
|
+
operatorIds?: number[];
|
|
243
|
+
}
|
|
244
|
+
export interface AiAgentManualList {
|
|
245
|
+
contactIds?: number[];
|
|
246
|
+
phones?: string[];
|
|
247
|
+
customerIds?: number[];
|
|
248
|
+
}
|
|
249
|
+
export interface AiAgentAudienceInput {
|
|
250
|
+
filters?: AiAgentAudienceFilters;
|
|
251
|
+
manualInclude?: AiAgentManualList;
|
|
252
|
+
manualExclude?: AiAgentManualList;
|
|
253
|
+
}
|
|
254
|
+
export interface AiAgentTriggerInput {
|
|
255
|
+
type: AiAgentTriggerType;
|
|
256
|
+
config?: {
|
|
257
|
+
timeoutMinutes?: number;
|
|
258
|
+
keywords?: string[];
|
|
259
|
+
startTime?: string;
|
|
260
|
+
endTime?: string;
|
|
261
|
+
timezone?: string;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
export interface AiAgentKnowledgeEntryInput {
|
|
265
|
+
title: string;
|
|
266
|
+
content: string;
|
|
267
|
+
fileId?: number;
|
|
268
|
+
fileName?: string;
|
|
269
|
+
fileType?: string;
|
|
270
|
+
fileSize?: number;
|
|
271
|
+
order?: number;
|
|
272
|
+
}
|
|
273
|
+
export interface CreateAiAgentInput {
|
|
274
|
+
name: string;
|
|
275
|
+
description?: string;
|
|
276
|
+
enabled?: boolean;
|
|
277
|
+
systemPrompt: string;
|
|
278
|
+
model?: string;
|
|
279
|
+
temperature?: number;
|
|
280
|
+
maxTokens?: number;
|
|
281
|
+
maxTurnsPerChat?: number;
|
|
282
|
+
allowedActions: AiAgentActionType[];
|
|
283
|
+
proactiveConfig?: AiAgentProactiveConfig | null;
|
|
284
|
+
templateName?: string;
|
|
285
|
+
templateLanguage?: string;
|
|
286
|
+
templateVariableMapping?: Record<string, string>;
|
|
287
|
+
escalateToWalletId?: number;
|
|
288
|
+
escalateToUserId?: number;
|
|
289
|
+
escalateToUserIds?: number[];
|
|
290
|
+
triggers?: AiAgentTriggerInput[];
|
|
291
|
+
knowledgeEntries?: AiAgentKnowledgeEntryInput[];
|
|
292
|
+
audience?: AiAgentAudienceInput;
|
|
293
|
+
}
|
|
294
|
+
export type UpdateAiAgentInput = Partial<CreateAiAgentInput>;
|
|
295
|
+
export interface AiAgentActionLogFilters {
|
|
296
|
+
agentId?: number;
|
|
297
|
+
chatId?: number;
|
|
298
|
+
actionType?: string;
|
|
299
|
+
success?: boolean;
|
|
300
|
+
dateFrom?: Date;
|
|
301
|
+
dateTo?: Date;
|
|
302
|
+
page?: number;
|
|
303
|
+
perPage?: number;
|
|
304
|
+
}
|
|
305
|
+
export interface PaginatedActionLogs {
|
|
306
|
+
data: AiAgentActionLog[];
|
|
307
|
+
page: {
|
|
308
|
+
totalRows: number;
|
|
309
|
+
current: number;
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
export interface AiAgentAudiencePreview {
|
|
313
|
+
data: WppContactWithCustomer[];
|
|
314
|
+
page: {
|
|
315
|
+
totalRows: number;
|
|
316
|
+
current: number;
|
|
317
|
+
};
|
|
318
|
+
}
|