livekit-server-sdk 2.14.1 → 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.
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var ConnectorClient_exports = {};
20
+ __export(ConnectorClient_exports, {
21
+ ConnectorClient: () => ConnectorClient
22
+ });
23
+ module.exports = __toCommonJS(ConnectorClient_exports);
24
+ var import_protocol = require("@livekit/protocol");
25
+ var import_ServiceBase = require("./ServiceBase.cjs");
26
+ var import_TwirpRPC = require("./TwirpRPC.cjs");
27
+ const svc = "Connector";
28
+ class ConnectorClient extends import_ServiceBase.ServiceBase {
29
+ /**
30
+ * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
31
+ * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
32
+ * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
33
+ * @param options - client options
34
+ */
35
+ constructor(host, apiKey, secret, options) {
36
+ super(apiKey, secret);
37
+ const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
38
+ this.rpc = new import_TwirpRPC.TwirpRpc(host, import_TwirpRPC.livekitPackage, rpcOptions);
39
+ }
40
+ /**
41
+ * Initiate an outbound WhatsApp call
42
+ *
43
+ * @param options - WhatsApp call options
44
+ * @returns Promise containing the WhatsApp call ID and room name
45
+ */
46
+ async dialWhatsAppCall(options) {
47
+ const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || "";
48
+ const roomName = options.roomName || "";
49
+ const participantIdentity = options.participantIdentity || "";
50
+ const participantName = options.participantName || "";
51
+ const participantMetadata = options.participantMetadata || "";
52
+ const destinationCountry = options.destinationCountry || "";
53
+ const req = new import_protocol.DialWhatsAppCallRequest({
54
+ whatsappPhoneNumberId: options.whatsappPhoneNumberId,
55
+ whatsappToPhoneNumber: options.whatsappToPhoneNumber,
56
+ whatsappApiKey: options.whatsappApiKey,
57
+ whatsappCloudApiVersion: options.whatsappCloudApiVersion,
58
+ whatsappBizOpaqueCallbackData,
59
+ roomName,
60
+ agents: options.agents,
61
+ participantIdentity,
62
+ participantName,
63
+ participantMetadata,
64
+ participantAttributes: options.participantAttributes,
65
+ destinationCountry
66
+ }).toJson();
67
+ const data = await this.rpc.request(
68
+ svc,
69
+ "DialWhatsAppCall",
70
+ req,
71
+ await this.authHeader({ roomCreate: true })
72
+ );
73
+ return import_protocol.DialWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
74
+ }
75
+ /**
76
+ * Accept an inbound WhatsApp call
77
+ *
78
+ * @param options - WhatsApp call accept options
79
+ * @returns Promise containing the room name
80
+ */
81
+ async acceptWhatsAppCall(options) {
82
+ const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || "";
83
+ const roomName = options.roomName || "";
84
+ const participantIdentity = options.participantIdentity || "";
85
+ const participantName = options.participantName || "";
86
+ const participantMetadata = options.participantMetadata || "";
87
+ const destinationCountry = options.destinationCountry || "";
88
+ const req = new import_protocol.AcceptWhatsAppCallRequest({
89
+ whatsappPhoneNumberId: options.whatsappPhoneNumberId,
90
+ whatsappApiKey: options.whatsappApiKey,
91
+ whatsappCloudApiVersion: options.whatsappCloudApiVersion,
92
+ whatsappCallId: options.whatsappCallId,
93
+ whatsappBizOpaqueCallbackData,
94
+ sdp: options.sdp,
95
+ roomName,
96
+ agents: options.agents,
97
+ participantIdentity,
98
+ participantName,
99
+ participantMetadata,
100
+ participantAttributes: options.participantAttributes,
101
+ destinationCountry
102
+ }).toJson();
103
+ const data = await this.rpc.request(
104
+ svc,
105
+ "AcceptWhatsAppCall",
106
+ req,
107
+ await this.authHeader({ roomCreate: true })
108
+ );
109
+ return import_protocol.AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
110
+ }
111
+ /**
112
+ * Connect an established WhatsApp call (used for business-initiated calls)
113
+ *
114
+ * @param whatsappCallId - Call ID sent by Meta
115
+ * @param sdp - Session description from Meta
116
+ */
117
+ async connectWhatsAppCall(whatsappCallId, sdp) {
118
+ const req = new import_protocol.ConnectWhatsAppCallRequest({
119
+ whatsappCallId,
120
+ sdp
121
+ }).toJson();
122
+ const data = await this.rpc.request(
123
+ svc,
124
+ "ConnectWhatsAppCall",
125
+ req,
126
+ await this.authHeader({ roomCreate: true })
127
+ );
128
+ return import_protocol.ConnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
129
+ }
130
+ /**
131
+ * Disconnect an active WhatsApp call
132
+ *
133
+ * @param whatsappCallId - Call ID sent by Meta
134
+ * @param whatsappApiKey - The API key of the business that is disconnecting the call
135
+ */
136
+ async disconnectWhatsAppCall(whatsappCallId, whatsappApiKey) {
137
+ const req = new import_protocol.DisconnectWhatsAppCallRequest({
138
+ whatsappCallId,
139
+ whatsappApiKey
140
+ }).toJson();
141
+ const data = await this.rpc.request(
142
+ svc,
143
+ "DisconnectWhatsAppCall",
144
+ req,
145
+ await this.authHeader({ roomCreate: true })
146
+ );
147
+ return import_protocol.DisconnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
148
+ }
149
+ /**
150
+ * Connect a Twilio call to a LiveKit room
151
+ *
152
+ * @param options - Twilio call connection options
153
+ * @returns Promise containing the WebSocket connect URL for Twilio media stream
154
+ */
155
+ async connectTwilioCall(options) {
156
+ const participantIdentity = options.participantIdentity || "";
157
+ const participantName = options.participantName || "";
158
+ const participantMetadata = options.participantMetadata || "";
159
+ const destinationCountry = options.destinationCountry || "";
160
+ const req = new import_protocol.ConnectTwilioCallRequest({
161
+ twilioCallDirection: options.twilioCallDirection,
162
+ roomName: options.roomName,
163
+ agents: options.agents,
164
+ participantIdentity,
165
+ participantName,
166
+ participantMetadata,
167
+ participantAttributes: options.participantAttributes,
168
+ destinationCountry
169
+ }).toJson();
170
+ const data = await this.rpc.request(
171
+ svc,
172
+ "ConnectTwilioCall",
173
+ req,
174
+ await this.authHeader({ roomCreate: true })
175
+ );
176
+ return import_protocol.ConnectTwilioCallResponse.fromJson(data, { ignoreUnknownFields: true });
177
+ }
178
+ }
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 && (module.exports = {
181
+ ConnectorClient
182
+ });
183
+ //# sourceMappingURL=ConnectorClient.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ConnectorClient.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n ConnectTwilioCallRequest_TwilioCallDirection,\n RoomAgentDispatch,\n SessionDescription,\n} from '@livekit/protocol';\nimport {\n AcceptWhatsAppCallRequest,\n AcceptWhatsAppCallResponse,\n ConnectTwilioCallRequest,\n ConnectTwilioCallResponse,\n ConnectWhatsAppCallRequest,\n ConnectWhatsAppCallResponse,\n DialWhatsAppCallRequest,\n DialWhatsAppCallResponse,\n DisconnectWhatsAppCallRequest,\n DisconnectWhatsAppCallResponse,\n} from '@livekit/protocol';\nimport type { ClientOptions } from './ClientOptions.js';\nimport { ServiceBase } from './ServiceBase.js';\nimport { type Rpc, TwirpRpc, livekitPackage } from './TwirpRPC.js';\n\nconst svc = 'Connector';\n\n// WhatsApp types\nexport interface DialWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is initiating the call */\n whatsappPhoneNumberId: string;\n /** Required - The number of the user that is supposed to receive the call */\n whatsappToPhoneNumber: string;\n /** Required - The API key of the business that is initiating the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\nexport interface AcceptWhatsAppCallOptions {\n /** Required - The identifier of the WhatsApp phone number that is connecting the call */\n whatsappPhoneNumberId: string;\n /** Required - The API key of the business that is connecting the call */\n whatsappApiKey: string;\n /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */\n whatsappCloudApiVersion: string;\n /** Required - Call ID sent by Meta */\n whatsappCallId: string;\n /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */\n whatsappBizOpaqueCallbackData?: string;\n /** Required - The call accept webhook comes with SDP from Meta */\n sdp: SessionDescription;\n /** Optional - What LiveKit room should this participant be connected to */\n roomName?: string;\n /** Optional - Agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional - Identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional - Name of the participant in LiveKit room */\n participantName?: string;\n /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n// Twilio types\nexport interface ConnectTwilioCallOptions {\n /** The direction of the call */\n twilioCallDirection: ConnectTwilioCallRequest_TwilioCallDirection;\n /** What LiveKit room should this call be connected to */\n roomName: string;\n /** Optional agents to dispatch the call to */\n agents?: RoomAgentDispatch[];\n /** Optional identity of the participant in LiveKit room */\n participantIdentity?: string;\n /** Optional name of the participant in LiveKit room */\n participantName?: string;\n /** Optional user-defined metadata. Will be attached to a created Participant in the room. */\n participantMetadata?: string;\n /** Optional user-defined attributes. Will be attached to a created Participant in the room. */\n participantAttributes?: { [key: string]: string };\n /** Country where the call terminates as ISO 3166-1 alpha-2 */\n destinationCountry?: string;\n}\n\n/**\n * Client to access Connector APIs for WhatsApp and Twilio integrations\n */\nexport class ConnectorClient extends ServiceBase {\n private readonly rpc: Rpc;\n\n /**\n * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'\n * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY\n * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET\n * @param options - client options\n */\n constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions) {\n super(apiKey, secret);\n const rpcOptions = options?.requestTimeout\n ? { requestTimeout: options.requestTimeout }\n : undefined;\n this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);\n }\n\n /**\n * Initiate an outbound WhatsApp call\n *\n * @param options - WhatsApp call options\n * @returns Promise containing the WhatsApp call ID and room name\n */\n async dialWhatsAppCall(options: DialWhatsAppCallOptions): Promise<DialWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new DialWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappToPhoneNumber: options.whatsappToPhoneNumber,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappBizOpaqueCallbackData,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DialWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DialWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Accept an inbound WhatsApp call\n *\n * @param options - WhatsApp call accept options\n * @returns Promise containing the room name\n */\n async acceptWhatsAppCall(\n options: AcceptWhatsAppCallOptions,\n ): Promise<AcceptWhatsAppCallResponse> {\n const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || '';\n const roomName = options.roomName || '';\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new AcceptWhatsAppCallRequest({\n whatsappPhoneNumberId: options.whatsappPhoneNumberId,\n whatsappApiKey: options.whatsappApiKey,\n whatsappCloudApiVersion: options.whatsappCloudApiVersion,\n whatsappCallId: options.whatsappCallId,\n whatsappBizOpaqueCallbackData,\n sdp: options.sdp,\n roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'AcceptWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect an established WhatsApp call (used for business-initiated calls)\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param sdp - Session description from Meta\n */\n async connectWhatsAppCall(\n whatsappCallId: string,\n sdp: SessionDescription,\n ): Promise<ConnectWhatsAppCallResponse> {\n const req = new ConnectWhatsAppCallRequest({\n whatsappCallId,\n sdp,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Disconnect an active WhatsApp call\n *\n * @param whatsappCallId - Call ID sent by Meta\n * @param whatsappApiKey - The API key of the business that is disconnecting the call\n */\n async disconnectWhatsAppCall(\n whatsappCallId: string,\n whatsappApiKey: string,\n ): Promise<DisconnectWhatsAppCallResponse> {\n const req = new DisconnectWhatsAppCallRequest({\n whatsappCallId,\n whatsappApiKey,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'DisconnectWhatsAppCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return DisconnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n\n /**\n * Connect a Twilio call to a LiveKit room\n *\n * @param options - Twilio call connection options\n * @returns Promise containing the WebSocket connect URL for Twilio media stream\n */\n async connectTwilioCall(options: ConnectTwilioCallOptions): Promise<ConnectTwilioCallResponse> {\n const participantIdentity = options.participantIdentity || '';\n const participantName = options.participantName || '';\n const participantMetadata = options.participantMetadata || '';\n const destinationCountry = options.destinationCountry || '';\n\n const req = new ConnectTwilioCallRequest({\n twilioCallDirection: options.twilioCallDirection,\n roomName: options.roomName,\n agents: options.agents,\n participantIdentity,\n participantName,\n participantMetadata,\n participantAttributes: options.participantAttributes,\n destinationCountry,\n }).toJson();\n\n const data = await this.rpc.request(\n svc,\n 'ConnectTwilioCall',\n req,\n await this.authHeader({ roomCreate: true }),\n );\n return ConnectTwilioCallResponse.fromJson(data, { ignoreUnknownFields: true });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,sBAWO;AAEP,yBAA4B;AAC5B,sBAAmD;AAEnD,MAAM,MAAM;AAkFL,MAAM,wBAAwB,+BAAY;AAAA;AAAA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Y,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,+CAA+B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EACpF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,kBAAkB,SAAuE;AAC7F,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,kBAAkB,QAAQ,mBAAmB;AACnD,UAAM,sBAAsB,QAAQ,uBAAuB;AAC3D,UAAM,qBAAqB,QAAQ,sBAAsB;AAEzD,UAAM,MAAM,IAAI,yCAAyB;AAAA,MACvC,qBAAqB,QAAQ;AAAA,MAC7B,UAAU,QAAQ;AAAA,MAClB,QAAQ,QAAQ;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA,uBAAuB,QAAQ;AAAA,MAC/B;AAAA,IACF,CAAC,EAAE,OAAO;AAEV,UAAM,OAAO,MAAM,KAAK,IAAI;AAAA,MAC1B;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM,KAAK,WAAW,EAAE,YAAY,KAAK,CAAC;AAAA,IAC5C;AACA,WAAO,0CAA0B,SAAS,MAAM,EAAE,qBAAqB,KAAK,CAAC;AAAA,EAC/E;AACF;","names":[]}
@@ -0,0 +1,134 @@
1
+ import { RoomAgentDispatch, SessionDescription, ConnectTwilioCallRequest_TwilioCallDirection, DialWhatsAppCallResponse, AcceptWhatsAppCallResponse, ConnectWhatsAppCallResponse, DisconnectWhatsAppCallResponse, ConnectTwilioCallResponse } from '@livekit/protocol';
2
+ import { ClientOptions } from './ClientOptions.cjs';
3
+ import { ServiceBase } from './ServiceBase.cjs';
4
+ import './grants.cjs';
5
+ import 'jose';
6
+
7
+ interface DialWhatsAppCallOptions {
8
+ /** Required - The identifier of the WhatsApp phone number that is initiating the call */
9
+ whatsappPhoneNumberId: string;
10
+ /** Required - The number of the user that is supposed to receive the call */
11
+ whatsappToPhoneNumber: string;
12
+ /** Required - The API key of the business that is initiating the call */
13
+ whatsappApiKey: string;
14
+ /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */
15
+ whatsappCloudApiVersion: string;
16
+ /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */
17
+ whatsappBizOpaqueCallbackData?: string;
18
+ /** Optional - What LiveKit room should this participant be connected to */
19
+ roomName?: string;
20
+ /** Optional - Agents to dispatch the call to */
21
+ agents?: RoomAgentDispatch[];
22
+ /** Optional - Identity of the participant in LiveKit room */
23
+ participantIdentity?: string;
24
+ /** Optional - Name of the participant in LiveKit room */
25
+ participantName?: string;
26
+ /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */
27
+ participantMetadata?: string;
28
+ /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */
29
+ participantAttributes?: {
30
+ [key: string]: string;
31
+ };
32
+ /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
33
+ destinationCountry?: string;
34
+ }
35
+ interface AcceptWhatsAppCallOptions {
36
+ /** Required - The identifier of the WhatsApp phone number that is connecting the call */
37
+ whatsappPhoneNumberId: string;
38
+ /** Required - The API key of the business that is connecting the call */
39
+ whatsappApiKey: string;
40
+ /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */
41
+ whatsappCloudApiVersion: string;
42
+ /** Required - Call ID sent by Meta */
43
+ whatsappCallId: string;
44
+ /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */
45
+ whatsappBizOpaqueCallbackData?: string;
46
+ /** Required - The call accept webhook comes with SDP from Meta */
47
+ sdp: SessionDescription;
48
+ /** Optional - What LiveKit room should this participant be connected to */
49
+ roomName?: string;
50
+ /** Optional - Agents to dispatch the call to */
51
+ agents?: RoomAgentDispatch[];
52
+ /** Optional - Identity of the participant in LiveKit room */
53
+ participantIdentity?: string;
54
+ /** Optional - Name of the participant in LiveKit room */
55
+ participantName?: string;
56
+ /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */
57
+ participantMetadata?: string;
58
+ /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */
59
+ participantAttributes?: {
60
+ [key: string]: string;
61
+ };
62
+ /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
63
+ destinationCountry?: string;
64
+ }
65
+ interface ConnectTwilioCallOptions {
66
+ /** The direction of the call */
67
+ twilioCallDirection: ConnectTwilioCallRequest_TwilioCallDirection;
68
+ /** What LiveKit room should this call be connected to */
69
+ roomName: string;
70
+ /** Optional agents to dispatch the call to */
71
+ agents?: RoomAgentDispatch[];
72
+ /** Optional identity of the participant in LiveKit room */
73
+ participantIdentity?: string;
74
+ /** Optional name of the participant in LiveKit room */
75
+ participantName?: string;
76
+ /** Optional user-defined metadata. Will be attached to a created Participant in the room. */
77
+ participantMetadata?: string;
78
+ /** Optional user-defined attributes. Will be attached to a created Participant in the room. */
79
+ participantAttributes?: {
80
+ [key: string]: string;
81
+ };
82
+ /** Country where the call terminates as ISO 3166-1 alpha-2 */
83
+ destinationCountry?: string;
84
+ }
85
+ /**
86
+ * Client to access Connector APIs for WhatsApp and Twilio integrations
87
+ */
88
+ declare class ConnectorClient extends ServiceBase {
89
+ private readonly rpc;
90
+ /**
91
+ * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
92
+ * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
93
+ * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
94
+ * @param options - client options
95
+ */
96
+ constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions);
97
+ /**
98
+ * Initiate an outbound WhatsApp call
99
+ *
100
+ * @param options - WhatsApp call options
101
+ * @returns Promise containing the WhatsApp call ID and room name
102
+ */
103
+ dialWhatsAppCall(options: DialWhatsAppCallOptions): Promise<DialWhatsAppCallResponse>;
104
+ /**
105
+ * Accept an inbound WhatsApp call
106
+ *
107
+ * @param options - WhatsApp call accept options
108
+ * @returns Promise containing the room name
109
+ */
110
+ acceptWhatsAppCall(options: AcceptWhatsAppCallOptions): Promise<AcceptWhatsAppCallResponse>;
111
+ /**
112
+ * Connect an established WhatsApp call (used for business-initiated calls)
113
+ *
114
+ * @param whatsappCallId - Call ID sent by Meta
115
+ * @param sdp - Session description from Meta
116
+ */
117
+ connectWhatsAppCall(whatsappCallId: string, sdp: SessionDescription): Promise<ConnectWhatsAppCallResponse>;
118
+ /**
119
+ * Disconnect an active WhatsApp call
120
+ *
121
+ * @param whatsappCallId - Call ID sent by Meta
122
+ * @param whatsappApiKey - The API key of the business that is disconnecting the call
123
+ */
124
+ disconnectWhatsAppCall(whatsappCallId: string, whatsappApiKey: string): Promise<DisconnectWhatsAppCallResponse>;
125
+ /**
126
+ * Connect a Twilio call to a LiveKit room
127
+ *
128
+ * @param options - Twilio call connection options
129
+ * @returns Promise containing the WebSocket connect URL for Twilio media stream
130
+ */
131
+ connectTwilioCall(options: ConnectTwilioCallOptions): Promise<ConnectTwilioCallResponse>;
132
+ }
133
+
134
+ export { type AcceptWhatsAppCallOptions, type ConnectTwilioCallOptions, ConnectorClient, type DialWhatsAppCallOptions };
@@ -0,0 +1,131 @@
1
+ import type { ConnectTwilioCallRequest_TwilioCallDirection, RoomAgentDispatch, SessionDescription } from '@livekit/protocol';
2
+ import { AcceptWhatsAppCallResponse, ConnectTwilioCallResponse, ConnectWhatsAppCallResponse, DialWhatsAppCallResponse, DisconnectWhatsAppCallResponse } from '@livekit/protocol';
3
+ import type { ClientOptions } from './ClientOptions.js';
4
+ import { ServiceBase } from './ServiceBase.js';
5
+ export interface DialWhatsAppCallOptions {
6
+ /** Required - The identifier of the WhatsApp phone number that is initiating the call */
7
+ whatsappPhoneNumberId: string;
8
+ /** Required - The number of the user that is supposed to receive the call */
9
+ whatsappToPhoneNumber: string;
10
+ /** Required - The API key of the business that is initiating the call */
11
+ whatsappApiKey: string;
12
+ /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */
13
+ whatsappCloudApiVersion: string;
14
+ /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */
15
+ whatsappBizOpaqueCallbackData?: string;
16
+ /** Optional - What LiveKit room should this participant be connected to */
17
+ roomName?: string;
18
+ /** Optional - Agents to dispatch the call to */
19
+ agents?: RoomAgentDispatch[];
20
+ /** Optional - Identity of the participant in LiveKit room */
21
+ participantIdentity?: string;
22
+ /** Optional - Name of the participant in LiveKit room */
23
+ participantName?: string;
24
+ /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */
25
+ participantMetadata?: string;
26
+ /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */
27
+ participantAttributes?: {
28
+ [key: string]: string;
29
+ };
30
+ /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
31
+ destinationCountry?: string;
32
+ }
33
+ export interface AcceptWhatsAppCallOptions {
34
+ /** Required - The identifier of the WhatsApp phone number that is connecting the call */
35
+ whatsappPhoneNumberId: string;
36
+ /** Required - The API key of the business that is connecting the call */
37
+ whatsappApiKey: string;
38
+ /** Required - WhatsApp Cloud API version, eg: 23.0, 24.0, etc. */
39
+ whatsappCloudApiVersion: string;
40
+ /** Required - Call ID sent by Meta */
41
+ whatsappCallId: string;
42
+ /** Optional - An arbitrary string you can pass in that is useful for tracking and logging purposes */
43
+ whatsappBizOpaqueCallbackData?: string;
44
+ /** Required - The call accept webhook comes with SDP from Meta */
45
+ sdp: SessionDescription;
46
+ /** Optional - What LiveKit room should this participant be connected to */
47
+ roomName?: string;
48
+ /** Optional - Agents to dispatch the call to */
49
+ agents?: RoomAgentDispatch[];
50
+ /** Optional - Identity of the participant in LiveKit room */
51
+ participantIdentity?: string;
52
+ /** Optional - Name of the participant in LiveKit room */
53
+ participantName?: string;
54
+ /** Optional - User-defined metadata. Will be attached to a created Participant in the room. */
55
+ participantMetadata?: string;
56
+ /** Optional - User-defined attributes. Will be attached to a created Participant in the room. */
57
+ participantAttributes?: {
58
+ [key: string]: string;
59
+ };
60
+ /** Optional - Country where the call terminates as ISO 3166-1 alpha-2 */
61
+ destinationCountry?: string;
62
+ }
63
+ export interface ConnectTwilioCallOptions {
64
+ /** The direction of the call */
65
+ twilioCallDirection: ConnectTwilioCallRequest_TwilioCallDirection;
66
+ /** What LiveKit room should this call be connected to */
67
+ roomName: string;
68
+ /** Optional agents to dispatch the call to */
69
+ agents?: RoomAgentDispatch[];
70
+ /** Optional identity of the participant in LiveKit room */
71
+ participantIdentity?: string;
72
+ /** Optional name of the participant in LiveKit room */
73
+ participantName?: string;
74
+ /** Optional user-defined metadata. Will be attached to a created Participant in the room. */
75
+ participantMetadata?: string;
76
+ /** Optional user-defined attributes. Will be attached to a created Participant in the room. */
77
+ participantAttributes?: {
78
+ [key: string]: string;
79
+ };
80
+ /** Country where the call terminates as ISO 3166-1 alpha-2 */
81
+ destinationCountry?: string;
82
+ }
83
+ /**
84
+ * Client to access Connector APIs for WhatsApp and Twilio integrations
85
+ */
86
+ export declare class ConnectorClient extends ServiceBase {
87
+ private readonly rpc;
88
+ /**
89
+ * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
90
+ * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
91
+ * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
92
+ * @param options - client options
93
+ */
94
+ constructor(host: string, apiKey?: string, secret?: string, options?: ClientOptions);
95
+ /**
96
+ * Initiate an outbound WhatsApp call
97
+ *
98
+ * @param options - WhatsApp call options
99
+ * @returns Promise containing the WhatsApp call ID and room name
100
+ */
101
+ dialWhatsAppCall(options: DialWhatsAppCallOptions): Promise<DialWhatsAppCallResponse>;
102
+ /**
103
+ * Accept an inbound WhatsApp call
104
+ *
105
+ * @param options - WhatsApp call accept options
106
+ * @returns Promise containing the room name
107
+ */
108
+ acceptWhatsAppCall(options: AcceptWhatsAppCallOptions): Promise<AcceptWhatsAppCallResponse>;
109
+ /**
110
+ * Connect an established WhatsApp call (used for business-initiated calls)
111
+ *
112
+ * @param whatsappCallId - Call ID sent by Meta
113
+ * @param sdp - Session description from Meta
114
+ */
115
+ connectWhatsAppCall(whatsappCallId: string, sdp: SessionDescription): Promise<ConnectWhatsAppCallResponse>;
116
+ /**
117
+ * Disconnect an active WhatsApp call
118
+ *
119
+ * @param whatsappCallId - Call ID sent by Meta
120
+ * @param whatsappApiKey - The API key of the business that is disconnecting the call
121
+ */
122
+ disconnectWhatsAppCall(whatsappCallId: string, whatsappApiKey: string): Promise<DisconnectWhatsAppCallResponse>;
123
+ /**
124
+ * Connect a Twilio call to a LiveKit room
125
+ *
126
+ * @param options - Twilio call connection options
127
+ * @returns Promise containing the WebSocket connect URL for Twilio media stream
128
+ */
129
+ connectTwilioCall(options: ConnectTwilioCallOptions): Promise<ConnectTwilioCallResponse>;
130
+ }
131
+ //# sourceMappingURL=ConnectorClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectorClient.d.ts","sourceRoot":"","sources":["../src/ConnectorClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,4CAA4C,EAC5C,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,0BAA0B,EAE1B,yBAAyB,EAEzB,2BAA2B,EAE3B,wBAAwB,EAExB,8BAA8B,EAC/B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C,MAAM,WAAW,uBAAuB;IACtC,yFAAyF;IACzF,qBAAqB,EAAE,MAAM,CAAC;IAC9B,6EAA6E;IAC7E,qBAAqB,EAAE,MAAM,CAAC;IAC9B,yEAAyE;IACzE,cAAc,EAAE,MAAM,CAAC;IACvB,kEAAkE;IAClE,uBAAuB,EAAE,MAAM,CAAC;IAChC,sGAAsG;IACtG,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,MAAM,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAC7B,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,MAAM,C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AAC,EAAE,MAAM,CAAC;IAC7B,uDAAuD;IACvD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6FAA6F;IAC7F,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,+FAA+F;IAC/F,qBAAqB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAClD,8DAA8D;IAC9D,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,WAAW;IAC9C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAE1B;;;;;OAKG;gBACS,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa;IAQnF;;;;;OAKG;IACG,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAgC3F;;;;;OAKG;IACG,kBAAkB,CACtB,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,0BAA0B,CAAC;IAiCtC;;;;;OAKG;IACG,mBAAmB,CACvB,cAAc,EAAE,MAAM,EACtB,GAAG,EAAE,kBAAkB,GACtB,OAAO,CAAC,2BAA2B,CAAC;IAevC;;;;;OAKG;IACG,sBAAsB,CAC1B,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,8BAA8B,CAAC;IAe1C;;;;;OAKG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAyB/F"}
@@ -0,0 +1,170 @@
1
+ import {
2
+ AcceptWhatsAppCallRequest,
3
+ AcceptWhatsAppCallResponse,
4
+ ConnectTwilioCallRequest,
5
+ ConnectTwilioCallResponse,
6
+ ConnectWhatsAppCallRequest,
7
+ ConnectWhatsAppCallResponse,
8
+ DialWhatsAppCallRequest,
9
+ DialWhatsAppCallResponse,
10
+ DisconnectWhatsAppCallRequest,
11
+ DisconnectWhatsAppCallResponse
12
+ } from "@livekit/protocol";
13
+ import { ServiceBase } from "./ServiceBase.js";
14
+ import { TwirpRpc, livekitPackage } from "./TwirpRPC.js";
15
+ const svc = "Connector";
16
+ class ConnectorClient extends ServiceBase {
17
+ /**
18
+ * @param host - hostname including protocol. i.e. 'https://<project>.livekit.cloud'
19
+ * @param apiKey - API Key, can be set in env var LIVEKIT_API_KEY
20
+ * @param secret - API Secret, can be set in env var LIVEKIT_API_SECRET
21
+ * @param options - client options
22
+ */
23
+ constructor(host, apiKey, secret, options) {
24
+ super(apiKey, secret);
25
+ const rpcOptions = (options == null ? void 0 : options.requestTimeout) ? { requestTimeout: options.requestTimeout } : void 0;
26
+ this.rpc = new TwirpRpc(host, livekitPackage, rpcOptions);
27
+ }
28
+ /**
29
+ * Initiate an outbound WhatsApp call
30
+ *
31
+ * @param options - WhatsApp call options
32
+ * @returns Promise containing the WhatsApp call ID and room name
33
+ */
34
+ async dialWhatsAppCall(options) {
35
+ const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || "";
36
+ const roomName = options.roomName || "";
37
+ const participantIdentity = options.participantIdentity || "";
38
+ const participantName = options.participantName || "";
39
+ const participantMetadata = options.participantMetadata || "";
40
+ const destinationCountry = options.destinationCountry || "";
41
+ const req = new DialWhatsAppCallRequest({
42
+ whatsappPhoneNumberId: options.whatsappPhoneNumberId,
43
+ whatsappToPhoneNumber: options.whatsappToPhoneNumber,
44
+ whatsappApiKey: options.whatsappApiKey,
45
+ whatsappCloudApiVersion: options.whatsappCloudApiVersion,
46
+ whatsappBizOpaqueCallbackData,
47
+ roomName,
48
+ agents: options.agents,
49
+ participantIdentity,
50
+ participantName,
51
+ participantMetadata,
52
+ participantAttributes: options.participantAttributes,
53
+ destinationCountry
54
+ }).toJson();
55
+ const data = await this.rpc.request(
56
+ svc,
57
+ "DialWhatsAppCall",
58
+ req,
59
+ await this.authHeader({ roomCreate: true })
60
+ );
61
+ return DialWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
62
+ }
63
+ /**
64
+ * Accept an inbound WhatsApp call
65
+ *
66
+ * @param options - WhatsApp call accept options
67
+ * @returns Promise containing the room name
68
+ */
69
+ async acceptWhatsAppCall(options) {
70
+ const whatsappBizOpaqueCallbackData = options.whatsappBizOpaqueCallbackData || "";
71
+ const roomName = options.roomName || "";
72
+ const participantIdentity = options.participantIdentity || "";
73
+ const participantName = options.participantName || "";
74
+ const participantMetadata = options.participantMetadata || "";
75
+ const destinationCountry = options.destinationCountry || "";
76
+ const req = new AcceptWhatsAppCallRequest({
77
+ whatsappPhoneNumberId: options.whatsappPhoneNumberId,
78
+ whatsappApiKey: options.whatsappApiKey,
79
+ whatsappCloudApiVersion: options.whatsappCloudApiVersion,
80
+ whatsappCallId: options.whatsappCallId,
81
+ whatsappBizOpaqueCallbackData,
82
+ sdp: options.sdp,
83
+ roomName,
84
+ agents: options.agents,
85
+ participantIdentity,
86
+ participantName,
87
+ participantMetadata,
88
+ participantAttributes: options.participantAttributes,
89
+ destinationCountry
90
+ }).toJson();
91
+ const data = await this.rpc.request(
92
+ svc,
93
+ "AcceptWhatsAppCall",
94
+ req,
95
+ await this.authHeader({ roomCreate: true })
96
+ );
97
+ return AcceptWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
98
+ }
99
+ /**
100
+ * Connect an established WhatsApp call (used for business-initiated calls)
101
+ *
102
+ * @param whatsappCallId - Call ID sent by Meta
103
+ * @param sdp - Session description from Meta
104
+ */
105
+ async connectWhatsAppCall(whatsappCallId, sdp) {
106
+ const req = new ConnectWhatsAppCallRequest({
107
+ whatsappCallId,
108
+ sdp
109
+ }).toJson();
110
+ const data = await this.rpc.request(
111
+ svc,
112
+ "ConnectWhatsAppCall",
113
+ req,
114
+ await this.authHeader({ roomCreate: true })
115
+ );
116
+ return ConnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
117
+ }
118
+ /**
119
+ * Disconnect an active WhatsApp call
120
+ *
121
+ * @param whatsappCallId - Call ID sent by Meta
122
+ * @param whatsappApiKey - The API key of the business that is disconnecting the call
123
+ */
124
+ async disconnectWhatsAppCall(whatsappCallId, whatsappApiKey) {
125
+ const req = new DisconnectWhatsAppCallRequest({
126
+ whatsappCallId,
127
+ whatsappApiKey
128
+ }).toJson();
129
+ const data = await this.rpc.request(
130
+ svc,
131
+ "DisconnectWhatsAppCall",
132
+ req,
133
+ await this.authHeader({ roomCreate: true })
134
+ );
135
+ return DisconnectWhatsAppCallResponse.fromJson(data, { ignoreUnknownFields: true });
136
+ }
137
+ /**
138
+ * Connect a Twilio call to a LiveKit room
139
+ *
140
+ * @param options - Twilio call connection options
141
+ * @returns Promise containing the WebSocket connect URL for Twilio media stream
142
+ */
143
+ async connectTwilioCall(options) {
144
+ const participantIdentity = options.participantIdentity || "";
145
+ const participantName = options.participantName || "";
146
+ const participantMetadata = options.participantMetadata || "";
147
+ const destinationCountry = options.destinationCountry || "";
148
+ const req = new ConnectTwilioCallRequest({
149
+ twilioCallDirection: options.twilioCallDirection,
150
+ roomName: options.roomName,
151
+ agents: options.agents,
152
+ participantIdentity,
153
+ participantName,
154
+ participantMetadata,
155
+ participantAttributes: options.participantAttributes,
156
+ destinationCountry
157
+ }).toJson();
158
+ const data = await this.rpc.request(
159
+ svc,
160
+ "ConnectTwilioCall",
161
+ req,
162
+ await this.authHeader({ roomCreate: true })
163
+ );
164
+ return ConnectTwilioCallResponse.fromJson(data, { ignoreUnknownFields: true });
165
+ }
166
+ }
167
+ export {
168
+ ConnectorClient
169
+ };
170
+ //# sourceMappingURL=ConnectorClient.js.map