rez_core 2.3.1 → 2.3.4
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/app.module.js +2 -0
- package/dist/app.module.js.map +1 -1
- package/dist/module/enterprise/repository/school.repository.js +0 -1
- package/dist/module/enterprise/repository/school.repository.js.map +1 -1
- package/dist/module/filter/repository/saved-filter.repository.js +0 -1
- package/dist/module/filter/repository/saved-filter.repository.js.map +1 -1
- package/dist/module/integration/controller/integration.controller.d.ts +8 -1
- package/dist/module/integration/controller/integration.controller.js +22 -0
- package/dist/module/integration/controller/integration.controller.js.map +1 -1
- package/dist/module/integration/dto/create-config.dto.d.ts +7 -0
- package/dist/module/integration/dto/create-config.dto.js +29 -1
- package/dist/module/integration/dto/create-config.dto.js.map +1 -1
- package/dist/module/integration/factories/sms.factory.d.ts +9 -1
- package/dist/module/integration/factories/sms.factory.js +36 -4
- package/dist/module/integration/factories/sms.factory.js.map +1 -1
- package/dist/module/integration/factories/whatsapp.factory.d.ts +5 -1
- package/dist/module/integration/factories/whatsapp.factory.js +14 -2
- package/dist/module/integration/factories/whatsapp.factory.js.map +1 -1
- package/dist/module/integration/integration.module.js +10 -0
- package/dist/module/integration/integration.module.js.map +1 -1
- package/dist/module/integration/service/integration.service.d.ts +7 -0
- package/dist/module/integration/service/integration.service.js +51 -0
- package/dist/module/integration/service/integration.service.js.map +1 -1
- package/dist/module/integration/strategies/sms/gupshup-sms.strategy.d.ts +9 -0
- package/dist/module/integration/strategies/sms/gupshup-sms.strategy.js +104 -0
- package/dist/module/integration/strategies/sms/gupshup-sms.strategy.js.map +1 -0
- package/dist/module/integration/strategies/sms/msg91-sms.strategy.d.ts +9 -0
- package/dist/module/integration/strategies/sms/msg91-sms.strategy.js +113 -0
- package/dist/module/integration/strategies/sms/msg91-sms.strategy.js.map +1 -0
- package/dist/module/integration/strategies/sms/tubelight-sms.strategy.d.ts +9 -0
- package/dist/module/integration/strategies/sms/tubelight-sms.strategy.js +109 -0
- package/dist/module/integration/strategies/sms/tubelight-sms.strategy.js.map +1 -0
- package/dist/module/integration/strategies/telephone/ozonetel-voice.strategy.d.ts +7 -2
- package/dist/module/integration/strategies/telephone/ozonetel-voice.strategy.js +52 -5
- package/dist/module/integration/strategies/telephone/ozonetel-voice.strategy.js.map +1 -1
- package/dist/module/integration/strategies/whatsapp/gupshup-whatsapp.strategy.d.ts +19 -0
- package/dist/module/integration/strategies/whatsapp/gupshup-whatsapp.strategy.js +257 -0
- package/dist/module/integration/strategies/whatsapp/gupshup-whatsapp.strategy.js.map +1 -0
- package/dist/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.d.ts +22 -0
- package/dist/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.js +295 -0
- package/dist/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.js.map +1 -0
- package/dist/module/layout_preference/service/layout_preference.service.js +0 -2
- package/dist/module/layout_preference/service/layout_preference.service.js.map +1 -1
- package/dist/module/listmaster/service/list-master.service.js +0 -1
- package/dist/module/listmaster/service/list-master.service.js.map +1 -1
- package/dist/module/mapper/controller/field-mapper.controller.d.ts +6 -0
- package/dist/module/mapper/controller/field-mapper.controller.js +45 -0
- package/dist/module/mapper/controller/field-mapper.controller.js.map +1 -0
- package/dist/module/mapper/dto/field-mapper.dto.d.ts +11 -0
- package/dist/module/mapper/dto/field-mapper.dto.js +8 -0
- package/dist/module/mapper/dto/field-mapper.dto.js.map +1 -0
- package/dist/module/mapper/entity/field-lovs.entity.d.ts +7 -0
- package/dist/module/mapper/entity/field-lovs.entity.js +38 -0
- package/dist/module/mapper/entity/field-lovs.entity.js.map +1 -0
- package/dist/module/mapper/entity/field-mapper.entity.d.ts +12 -0
- package/dist/module/mapper/entity/field-mapper.entity.js +58 -0
- package/dist/module/mapper/entity/field-mapper.entity.js.map +1 -0
- package/dist/module/mapper/mapper.module.d.ts +2 -0
- package/dist/module/mapper/mapper.module.js +38 -0
- package/dist/module/mapper/mapper.module.js.map +1 -0
- package/dist/module/mapper/repository/field-lovs.repository.d.ts +8 -0
- package/dist/module/mapper/repository/field-lovs.repository.js +41 -0
- package/dist/module/mapper/repository/field-lovs.repository.js.map +1 -0
- package/dist/module/mapper/repository/field-mapper.repository.d.ts +9 -0
- package/dist/module/mapper/repository/field-mapper.repository.js +42 -0
- package/dist/module/mapper/repository/field-mapper.repository.js.map +1 -0
- package/dist/module/mapper/service/field-mapper.service.d.ts +16 -0
- package/dist/module/mapper/service/field-mapper.service.js +92 -0
- package/dist/module/mapper/service/field-mapper.service.js.map +1 -0
- package/dist/module/master/service/master.service.js +0 -2
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/repository/entity-table.repository.js +0 -1
- package/dist/module/meta/repository/entity-table.repository.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +0 -1
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +0 -2
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/meta/service/entity-table.service.js +0 -2
- package/dist/module/meta/service/entity-table.service.js.map +1 -1
- package/dist/module/meta/service/field-group.service.js +0 -1
- package/dist/module/meta/service/field-group.service.js.map +1 -1
- package/dist/module/module/service/module-access.service.js +0 -6
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/notification/service/email.service.js +0 -1
- package/dist/module/notification/service/email.service.js.map +1 -1
- package/dist/module/user/service/login.service.js +0 -1
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/workflow/entity/action.entity.d.ts +2 -0
- package/dist/module/workflow/entity/action.entity.js +8 -0
- package/dist/module/workflow/entity/action.entity.js.map +1 -1
- package/dist/module/workflow/repository/stage.repository.js +0 -1
- package/dist/module/workflow/repository/stage.repository.js.map +1 -1
- package/dist/module/workflow/service/action.service.js +0 -1
- package/dist/module/workflow/service/action.service.js.map +1 -1
- package/dist/module/workflow/service/comm-template.service.js +0 -1
- package/dist/module/workflow/service/comm-template.service.js.map +1 -1
- package/dist/module/workflow/service/populate-workflow.service.js +0 -5
- package/dist/module/workflow/service/populate-workflow.service.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +0 -1
- package/dist/module/workflow/service/task.service.js.map +1 -1
- package/dist/module/workflow/service/workflow-meta.service.js +0 -2
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js +0 -1
- package/dist/module/workflow-automation/service/workflow-automation-engine.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/docs/modules/integration.md +55 -1
- package/package.json +1 -1
- package/src/app.module.ts +2 -0
- package/src/module/enterprise/repository/school.repository.ts +0 -1
- package/src/module/filter/repository/saved-filter.repository.ts +0 -1
- package/src/module/integration/controller/integration.controller.ts +24 -0
- package/src/module/integration/dto/create-config.dto.ts +22 -0
- package/src/module/integration/factories/sms.factory.ts +39 -6
- package/src/module/integration/factories/whatsapp.factory.ts +10 -0
- package/src/module/integration/integration.module.ts +14 -0
- package/src/module/integration/service/integration.service.ts +107 -0
- package/src/module/integration/strategies/sms/gupshup-sms.strategy.ts +146 -0
- package/src/module/integration/strategies/sms/msg91-sms.strategy.ts +164 -0
- package/src/module/integration/strategies/sms/tubelight-sms.strategy.ts +163 -0
- package/src/module/integration/strategies/telephone/ozonetel-voice.strategy.ts +80 -7
- package/src/module/integration/strategies/whatsapp/gupshup-whatsapp.strategy.ts +360 -0
- package/src/module/integration/strategies/whatsapp/tubelight-whatsapp.strategy.ts +419 -0
- package/src/module/layout_preference/service/layout_preference.service.ts +0 -2
- package/src/module/listmaster/service/list-master.service.ts +1 -10
- package/src/module/mapper/controller/field-mapper.controller.ts +19 -0
- package/src/module/mapper/dto/field-mapper.dto.ts +14 -0
- package/src/module/mapper/entity/field-lovs.entity.ts +21 -0
- package/src/module/mapper/entity/field-mapper.entity.ts +36 -0
- package/src/module/mapper/mapper.module.ts +26 -0
- package/src/module/mapper/repository/field-lovs.repository.ts +22 -0
- package/src/module/mapper/repository/field-mapper.repository.ts +27 -0
- package/src/module/mapper/service/field-mapper.service.ts +91 -0
- package/src/module/master/service/master.service.ts +0 -2
- package/src/module/meta/repository/entity-table.repository.ts +0 -1
- package/src/module/meta/service/entity-dynamic.service.ts +1 -5
- package/src/module/meta/service/entity-service-impl.service.ts +0 -4
- package/src/module/meta/service/entity-table.service.ts +0 -2
- package/src/module/meta/service/field-group.service.ts +0 -1
- package/src/module/module/service/module-access.service.ts +0 -13
- package/src/module/notification/service/email.service.ts +0 -1
- package/src/module/user/service/login.service.ts +0 -1
- package/src/module/workflow/entity/action.entity.ts +6 -0
- package/src/module/workflow/repository/stage.repository.ts +1 -2
- package/src/module/workflow/service/action.service.ts +0 -1
- package/src/module/workflow/service/comm-template.service.ts +0 -1
- package/src/module/workflow/service/populate-workflow.service.ts +2 -12
- package/src/module/workflow/service/task.service.ts +0 -1
- package/src/module/workflow/service/workflow-meta.service.ts +1 -4
- package/src/module/workflow-automation/service/workflow-automation-engine.service.ts +0 -1
- package/src/resources/dev.properties.yaml +1 -1
- package/.vscode/extensions.json +0 -5
|
@@ -34,10 +34,21 @@ let OzonetelVoiceStrategy = class OzonetelVoiceStrategy {
|
|
|
34
34
|
timestamp: new Date(),
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
+
const agentStatus = await this.checkAgentStatus(config, token);
|
|
38
|
+
if (!agentStatus.isReady) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
provider: 'ozonetel',
|
|
42
|
+
service: 'THIRD_PARTY',
|
|
43
|
+
error: agentStatus.error ||
|
|
44
|
+
`Agent is not ready. Current state: ${agentStatus.state || 'Unknown'}. Please login to your agent dashboard.`,
|
|
45
|
+
timestamp: new Date(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
37
48
|
const url = `${this.baseUrl}/ca_apis/AgentManualDial`;
|
|
38
49
|
await axios_1.default.post(url, {
|
|
39
50
|
userName: config.userName,
|
|
40
|
-
agentID: config.external_user_id
|
|
51
|
+
agentID: config.external_user_id,
|
|
41
52
|
campaignName: config.campaignName,
|
|
42
53
|
customerNumber: to,
|
|
43
54
|
UCID: true,
|
|
@@ -92,19 +103,55 @@ let OzonetelVoiceStrategy = class OzonetelVoiceStrategy {
|
|
|
92
103
|
return null;
|
|
93
104
|
}
|
|
94
105
|
}
|
|
106
|
+
async checkAgentStatus(config, token) {
|
|
107
|
+
try {
|
|
108
|
+
const url = `${this.baseUrl}/ca_apis/AgentDetails`;
|
|
109
|
+
const response = await axios_1.default.post(url, {
|
|
110
|
+
userName: config.userName,
|
|
111
|
+
agentId: config.external_user_id,
|
|
112
|
+
}, {
|
|
113
|
+
headers: {
|
|
114
|
+
apiKey: config.apiKey,
|
|
115
|
+
'Content-Type': 'application/json',
|
|
116
|
+
Authorization: `Bearer ${token}`,
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
if (response.data?.status === 'success' && response.data?.message?.length > 0) {
|
|
120
|
+
const agentInfo = response.data.message[0];
|
|
121
|
+
const isReady = agentInfo.State?.toUpperCase() === 'READY';
|
|
122
|
+
return {
|
|
123
|
+
isReady,
|
|
124
|
+
state: agentInfo.State,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
return {
|
|
128
|
+
isReady: false,
|
|
129
|
+
error: 'Failed to retrieve agent details',
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
console.error('Failed to check agent status:', error);
|
|
134
|
+
return {
|
|
135
|
+
isReady: false,
|
|
136
|
+
error: axios_1.default.isAxiosError(error)
|
|
137
|
+
? error.response?.data?.message || error.message
|
|
138
|
+
: 'Unknown error checking agent status',
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
95
142
|
validateConfig(config) {
|
|
96
143
|
return !!(config &&
|
|
97
144
|
config.apiKey &&
|
|
98
145
|
config.campaignName &&
|
|
99
146
|
config.userName);
|
|
100
147
|
}
|
|
101
|
-
createUserSpecificConfig(baseConfig,
|
|
102
|
-
if (!
|
|
103
|
-
throw new Error('
|
|
148
|
+
createUserSpecificConfig(baseConfig, externalUserId) {
|
|
149
|
+
if (!externalUserId) {
|
|
150
|
+
throw new Error('External user ID is required for Ozonetel voice calls');
|
|
104
151
|
}
|
|
105
152
|
return {
|
|
106
153
|
...baseConfig,
|
|
107
|
-
|
|
154
|
+
external_user_id: externalUserId,
|
|
108
155
|
};
|
|
109
156
|
}
|
|
110
157
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ozonetel-voice.strategy.js","sourceRoot":"","sources":["../../../../../src/module/integration/strategies/telephone/ozonetel-voice.strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,iCAA0B;
|
|
1
|
+
{"version":3,"file":"ozonetel-voice.strategy.js","sourceRoot":"","sources":["../../../../../src/module/integration/strategies/telephone/ozonetel-voice.strategy.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAC5C,iCAA0B;AA+BnB,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAA3B;QACY,YAAO,GAAG,oCAAoC,CAAC;IAmMlE,CAAC;IAjMC,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAA2B;QAE3B,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YACjC,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,UAAU;gBACpB,OAAO,EAAE,aAAa;gBACtB,KAAK,EACH,kEAAkE;gBACpE,SAAS,EAAE,IAAI,IAAI,EAAE;aACtB,CAAC;QACJ,CAAC;QAED,IAAI,CAAC;YAEH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,QAAQ,EAAE,UAAU;oBACpB,OAA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;YACpB,MAAM,IAAI,KAAK,CACb,uDAAuD,CACxD,CAAC;QACJ,CAAC;QAED,OAAO;YACL,GAAG,UAAU;YACb,gBAAgB,EAAE,cAAc;SACjC,CAAC;IACJ,CAAC;CACF,CAAA;AApMY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;GACA,qBAAqB,CAoMjC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IntegrationStrategy, IntegrationResult } from '../integration.strategy';
|
|
2
|
+
interface GupshupConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
appName: string;
|
|
5
|
+
sourceNumber: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class GupshupWhatsAppStrategy implements IntegrationStrategy {
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private readonly defaultBaseUrl;
|
|
11
|
+
sendMessage(to: string, message: string, config: any): Promise<IntegrationResult>;
|
|
12
|
+
private prepareMessagePayload;
|
|
13
|
+
private formatPhoneNumber;
|
|
14
|
+
private extractErrorMessage;
|
|
15
|
+
validateConfig(config: any): boolean;
|
|
16
|
+
getAppInfo(config: GupshupConfig): Promise<any>;
|
|
17
|
+
getTemplates(config: GupshupConfig): Promise<any>;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var GupshupWhatsAppStrategy_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GupshupWhatsAppStrategy = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const axios_1 = require("axios");
|
|
13
|
+
let GupshupWhatsAppStrategy = GupshupWhatsAppStrategy_1 = class GupshupWhatsAppStrategy {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.logger = new common_1.Logger(GupshupWhatsAppStrategy_1.name);
|
|
16
|
+
this.defaultBaseUrl = 'https://api.gupshup.io/sm/api/v1';
|
|
17
|
+
}
|
|
18
|
+
async sendMessage(to, message, config) {
|
|
19
|
+
try {
|
|
20
|
+
if (!this.validateConfig(config)) {
|
|
21
|
+
throw new Error('Invalid Gupshup WhatsApp configuration');
|
|
22
|
+
}
|
|
23
|
+
const gupshupConfig = config;
|
|
24
|
+
const baseUrl = gupshupConfig.baseUrl || this.defaultBaseUrl;
|
|
25
|
+
const url = `${baseUrl}/msg`;
|
|
26
|
+
const payload = this.prepareMessagePayload(to, message, config);
|
|
27
|
+
const response = await axios_1.default.post(url, payload, {
|
|
28
|
+
headers: {
|
|
29
|
+
apikey: gupshupConfig.apiKey,
|
|
30
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
31
|
+
},
|
|
32
|
+
timeout: 30000,
|
|
33
|
+
});
|
|
34
|
+
if (response.data?.status === 'submitted' && response.data?.messageId) {
|
|
35
|
+
this.logger.log(`Gupshup WhatsApp message sent successfully to ${to}, messageId: ${response.data.messageId}`);
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
messageId: response.data.messageId,
|
|
39
|
+
provider: 'gupshup',
|
|
40
|
+
service: 'API',
|
|
41
|
+
timestamp: new Date(),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else if (response.data?.response?.id) {
|
|
45
|
+
this.logger.log(`Gupshup WhatsApp message sent successfully to ${to}, messageId: ${response.data.response.id}`);
|
|
46
|
+
return {
|
|
47
|
+
success: true,
|
|
48
|
+
messageId: response.data.response.id,
|
|
49
|
+
provider: 'gupshup',
|
|
50
|
+
service: 'API',
|
|
51
|
+
timestamp: new Date(),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error(response.data?.error?.message || 'Invalid response from Gupshup API');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
this.logger.error(`Failed to send Gupshup WhatsApp message to ${to}`, error.response?.data || error.message);
|
|
60
|
+
return {
|
|
61
|
+
success: false,
|
|
62
|
+
provider: 'gupshup',
|
|
63
|
+
service: 'API',
|
|
64
|
+
error: this.extractErrorMessage(error),
|
|
65
|
+
timestamp: new Date(),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
prepareMessagePayload(to, message, config) {
|
|
70
|
+
const gupshupConfig = config;
|
|
71
|
+
const params = new URLSearchParams();
|
|
72
|
+
params.append('channel', 'whatsapp');
|
|
73
|
+
params.append('source', gupshupConfig.sourceNumber);
|
|
74
|
+
params.append('destination', this.formatPhoneNumber(to));
|
|
75
|
+
params.append('src.name', gupshupConfig.appName);
|
|
76
|
+
if (config.messageType) {
|
|
77
|
+
switch (config.messageType) {
|
|
78
|
+
case 'template':
|
|
79
|
+
params.append('message', JSON.stringify({
|
|
80
|
+
type: 'template',
|
|
81
|
+
template: {
|
|
82
|
+
id: config.templateId,
|
|
83
|
+
params: config.templateParams || [],
|
|
84
|
+
},
|
|
85
|
+
}));
|
|
86
|
+
break;
|
|
87
|
+
case 'image':
|
|
88
|
+
params.append('message', JSON.stringify({
|
|
89
|
+
type: 'image',
|
|
90
|
+
originalUrl: config.mediaUrl,
|
|
91
|
+
previewUrl: config.previewUrl || config.mediaUrl,
|
|
92
|
+
caption: message || config.caption || '',
|
|
93
|
+
}));
|
|
94
|
+
break;
|
|
95
|
+
case 'document':
|
|
96
|
+
params.append('message', JSON.stringify({
|
|
97
|
+
type: 'file',
|
|
98
|
+
url: config.mediaUrl,
|
|
99
|
+
filename: config.filename || 'document',
|
|
100
|
+
caption: message || config.caption || '',
|
|
101
|
+
}));
|
|
102
|
+
break;
|
|
103
|
+
case 'audio':
|
|
104
|
+
params.append('message', JSON.stringify({
|
|
105
|
+
type: 'audio',
|
|
106
|
+
url: config.mediaUrl,
|
|
107
|
+
}));
|
|
108
|
+
break;
|
|
109
|
+
case 'video':
|
|
110
|
+
params.append('message', JSON.stringify({
|
|
111
|
+
type: 'video',
|
|
112
|
+
url: config.mediaUrl,
|
|
113
|
+
caption: message || config.caption || '',
|
|
114
|
+
}));
|
|
115
|
+
break;
|
|
116
|
+
case 'location':
|
|
117
|
+
params.append('message', JSON.stringify({
|
|
118
|
+
type: 'location',
|
|
119
|
+
longitude: config.longitude,
|
|
120
|
+
latitude: config.latitude,
|
|
121
|
+
name: config.locationName || '',
|
|
122
|
+
address: config.locationAddress || '',
|
|
123
|
+
}));
|
|
124
|
+
break;
|
|
125
|
+
case 'list':
|
|
126
|
+
params.append('message', JSON.stringify({
|
|
127
|
+
type: 'list',
|
|
128
|
+
title: config.listTitle || 'Select an option',
|
|
129
|
+
body: message,
|
|
130
|
+
globalButtons: config.globalButtons || [],
|
|
131
|
+
items: config.listItems || [],
|
|
132
|
+
}));
|
|
133
|
+
break;
|
|
134
|
+
case 'quick_reply':
|
|
135
|
+
params.append('message', JSON.stringify({
|
|
136
|
+
type: 'quick_reply',
|
|
137
|
+
content: {
|
|
138
|
+
type: 'text',
|
|
139
|
+
text: message,
|
|
140
|
+
},
|
|
141
|
+
options: config.quickReplyOptions || [],
|
|
142
|
+
}));
|
|
143
|
+
break;
|
|
144
|
+
default:
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (!config.messageType || !['template', 'image', 'document', 'audio', 'video', 'location', 'list', 'quick_reply'].includes(config.messageType)) {
|
|
149
|
+
params.append('message', JSON.stringify({
|
|
150
|
+
type: 'text',
|
|
151
|
+
text: message,
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
return params;
|
|
155
|
+
}
|
|
156
|
+
formatPhoneNumber(phoneNumber) {
|
|
157
|
+
let formatted = phoneNumber.replace(/[^\d+]/g, '');
|
|
158
|
+
if (!formatted.startsWith('+')) {
|
|
159
|
+
formatted = `+${formatted}`;
|
|
160
|
+
}
|
|
161
|
+
return formatted;
|
|
162
|
+
}
|
|
163
|
+
extractErrorMessage(error) {
|
|
164
|
+
if (error.response?.data?.error?.message) {
|
|
165
|
+
return error.response.data.error.message;
|
|
166
|
+
}
|
|
167
|
+
if (error.response?.data?.message) {
|
|
168
|
+
return error.response.data.message;
|
|
169
|
+
}
|
|
170
|
+
if (error.response?.data?.response?.details) {
|
|
171
|
+
return error.response.data.response.details;
|
|
172
|
+
}
|
|
173
|
+
if (error.message) {
|
|
174
|
+
return error.message;
|
|
175
|
+
}
|
|
176
|
+
return 'Unknown Gupshup API error';
|
|
177
|
+
}
|
|
178
|
+
validateConfig(config) {
|
|
179
|
+
if (!config || typeof config !== 'object') {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
if (!config.apiKey || !config.appName || !config.sourceNumber) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
if (config.messageType) {
|
|
186
|
+
switch (config.messageType) {
|
|
187
|
+
case 'template':
|
|
188
|
+
if (!config.templateId) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
break;
|
|
192
|
+
case 'image':
|
|
193
|
+
case 'document':
|
|
194
|
+
case 'audio':
|
|
195
|
+
case 'video':
|
|
196
|
+
if (!config.mediaUrl) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
case 'location':
|
|
201
|
+
if (typeof config.latitude !== 'number' ||
|
|
202
|
+
typeof config.longitude !== 'number') {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
case 'list':
|
|
207
|
+
if (!config.listItems || !Array.isArray(config.listItems)) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
case 'quick_reply':
|
|
212
|
+
if (!config.quickReplyOptions || !Array.isArray(config.quickReplyOptions)) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
async getAppInfo(config) {
|
|
221
|
+
try {
|
|
222
|
+
const baseUrl = config.baseUrl || this.defaultBaseUrl;
|
|
223
|
+
const url = `${baseUrl}/app`;
|
|
224
|
+
const response = await axios_1.default.get(url, {
|
|
225
|
+
headers: {
|
|
226
|
+
apikey: config.apiKey,
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
return response.data;
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
this.logger.error('Failed to get Gupshup app info', error.response?.data || error.message);
|
|
233
|
+
throw new Error(`Failed to get app info: ${this.extractErrorMessage(error)}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async getTemplates(config) {
|
|
237
|
+
try {
|
|
238
|
+
const baseUrl = config.baseUrl || this.defaultBaseUrl;
|
|
239
|
+
const url = `${baseUrl}/template/list/${config.appName}`;
|
|
240
|
+
const response = await axios_1.default.get(url, {
|
|
241
|
+
headers: {
|
|
242
|
+
apikey: config.apiKey,
|
|
243
|
+
},
|
|
244
|
+
});
|
|
245
|
+
return response.data;
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
this.logger.error('Failed to get Gupshup templates', error.response?.data || error.message);
|
|
249
|
+
throw new Error(`Failed to get templates: ${this.extractErrorMessage(error)}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
exports.GupshupWhatsAppStrategy = GupshupWhatsAppStrategy;
|
|
254
|
+
exports.GupshupWhatsAppStrategy = GupshupWhatsAppStrategy = GupshupWhatsAppStrategy_1 = __decorate([
|
|
255
|
+
(0, common_1.Injectable)()
|
|
256
|
+
], GupshupWhatsAppStrategy);
|
|
257
|
+
//# sourceMappingURL=gupshup-whatsapp.strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gupshup-whatsapp.strategy.js","sourceRoot":"","sources":["../../../../../src/module/integration/strategies/whatsapp/gupshup-whatsapp.strategy.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAoD;AACpD,iCAA6C;AA0CtC,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IAA7B;QACY,WAAM,GAAG,IAAI,eAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;QAClD,mBAAc,GAAG,kCAAkC,CAAC;IA0TvE,CAAC;IAxTC,KAAK,CAAC,WAAW,CACf,EAAU,EACV,OAAe,EACf,MAAW;QAEX,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC5D,CAAC;YAED,MAAM,aAAa,GAAG,MAAuB,CAAC;YAC9C,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,IAAI,CAAC,cAAc,CAAC;YAC7D,MAAM,GAAG,GAAG,GAAG,OAAO,MAAM,CAAC;YAE7B,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAEhE,MAAM,QAAQ,GAAsC,MAAM,eAAK,CAAC,IAAI,CAClE,GAAG,EACH,OAAO,EACP;gBACE,OAAO,EAAE;oBACP,MAAM,EAAE,aAAa,CAAC,MAAM;oBAC5B,cAAc,EAAE,mCAAmC;iBACpD;gBACD,OAAO,EAAE,KAAK;aACf,CACF,CAAC;YAEF,IAAI,QAAQ,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,IAAI,QAAQ,CAAC,IAAI,EAA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AkB,MAAM,CAAC,OAAO,EAAE,CAAC;YAEzD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;gBACpC,OAAO,EAAE;oBACP,MAAM,EAAE,MAAM,CAAC,MAAM;iBACtB;aACF,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,iCAAiC,EACjC,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,KAAK,CAAC,OAAO,CACtC,CAAC;YACF,MAAM,IAAI,KAAK,CACb,4BAA4B,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AA5TY,0DAAuB;kCAAvB,uBAAuB;IADnC,IAAA,mBAAU,GAAE;GACA,uBAAuB,CA4TnC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IntegrationResult, IntegrationStrategy } from '../integration.strategy';
|
|
2
|
+
interface TubelightWhatsAppConfig {
|
|
3
|
+
userName: string;
|
|
4
|
+
password: string;
|
|
5
|
+
tenantId: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
sourceNumber?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class TubelightWhatsAppStrategy implements IntegrationStrategy {
|
|
10
|
+
private readonly logger;
|
|
11
|
+
private readonly defaultBaseUrl;
|
|
12
|
+
sendMessage(to: string, message: string, config: any): Promise<IntegrationResult>;
|
|
13
|
+
private authenticate;
|
|
14
|
+
private prepareMessagePayload;
|
|
15
|
+
private formatPhoneNumber;
|
|
16
|
+
private extractErrorMessage;
|
|
17
|
+
validateConfig(config: any): boolean;
|
|
18
|
+
getAccountInfo(config: TubelightWhatsAppConfig): Promise<any>;
|
|
19
|
+
getTemplates(config: TubelightWhatsAppConfig): Promise<any>;
|
|
20
|
+
getMessageStatus(config: TubelightWhatsAppConfig, messageId: string): Promise<any>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|