@squidcloud/twilio-client 1.0.493
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/connectors/twilio/common/src/twilio-types.d.ts +224 -0
- package/dist/connectors/twilio/twilio-client/src/index.d.ts +2 -0
- package/dist/connectors/twilio/twilio-client/src/twilio-client.d.ts +18 -0
- package/dist/index.js +1 -0
- package/dist/internal-common/src/ai/voice-languages.d.ts +22 -0
- package/dist/internal-common/src/public-types/ai-agent.public-types.d.ts +1536 -0
- package/dist/internal-common/src/public-types/ai-common.public-types.d.ts +298 -0
- package/dist/internal-common/src/public-types/ai-knowledge-base.public-types.d.ts +2144 -0
- package/dist/internal-common/src/public-types/ai-voice.public-types.d.ts +200 -0
- package/dist/internal-common/src/public-types/backend.public-types.d.ts +61 -0
- package/dist/internal-common/src/public-types/communication.public-types.d.ts +30 -0
- package/dist/internal-common/src/public-types/extraction.public-types.d.ts +405 -0
- package/dist/internal-common/src/public-types/integration.public-types.d.ts +65 -0
- package/dist/internal-common/src/public-types/job.public-types.d.ts +87 -0
- package/dist/internal-common/src/public-types/metadata-filter.public-types.d.ts +106 -0
- package/dist/internal-common/src/public-types/secret.public-types.d.ts +82 -0
- package/package.json +25 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { VoiceLanguageMode } from '../../../../internal-common/src/ai/voice-languages';
|
|
2
|
+
import { AiVoiceGreetingMode } from '../../../../internal-common/src/public-types/ai-voice.public-types';
|
|
3
|
+
import { IntegrationId } from '../../../../internal-common/src/public-types/communication.public-types';
|
|
4
|
+
/** Twilio call id (`CA…`). */
|
|
5
|
+
export type CallSid = string;
|
|
6
|
+
/**
|
|
7
|
+
* Event type emitted by the Twilio connector for every incoming SMS it has verified. Subscribe with
|
|
8
|
+
* `@eventHandler(SMS_EVENT_TYPE)` to handle messages alongside (or instead of) the built-in agent reply.
|
|
9
|
+
* The payload is a {@link TwilioSmsEvent}.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SMS_EVENT_TYPE = "twilio-sms-event";
|
|
12
|
+
/** How the agent talks on a call when Twilio runs the voice loop. */
|
|
13
|
+
export declare const VOICE_MODES: readonly ["relay", "gather"];
|
|
14
|
+
/**
|
|
15
|
+
* `relay` streams the conversation in real time through Twilio ConversationRelay; `gather` is
|
|
16
|
+
* turn-based, speaking one complete answer per caller utterance over plain TwiML.
|
|
17
|
+
*/
|
|
18
|
+
export type VoiceMode = (typeof VOICE_MODES)[number];
|
|
19
|
+
/** Who runs the voice conversation on the agent's number. */
|
|
20
|
+
export declare const VOICE_ENGINES: readonly ["twilio", "elevenlabs", "openai"];
|
|
21
|
+
/**
|
|
22
|
+
* `twilio` answers with Twilio's own speech services and Squid's voice relay; `elevenlabs` hands the
|
|
23
|
+
* number to an ElevenLabs agent that speaks with ElevenLabs voices and calls the Squid agent as its brain;
|
|
24
|
+
* `openai` sends each call to an OpenAI realtime model that talks itself and asks the Squid agent whenever
|
|
25
|
+
* it needs knowledge or actions.
|
|
26
|
+
*/
|
|
27
|
+
export type VoiceEngine = (typeof VOICE_ENGINES)[number];
|
|
28
|
+
/**
|
|
29
|
+
* Per-agent options for a connected Twilio integration, stored on `connectedIntegrations[].options` of
|
|
30
|
+
* the agent. Set from the console's agent ability or with
|
|
31
|
+
* `squid.ai().agent(id).setAgentOptionInPath('connectedIntegrations[integrationId=<id>].options', ...)`.
|
|
32
|
+
* Saving the connection wires the number up; the outcome lands in {@link provisioning}.
|
|
33
|
+
*/
|
|
34
|
+
export interface AiAgentTwilioIntegrationOptions {
|
|
35
|
+
/** The agent's phone number on the Twilio account, E.164. Calls to it ring the agent; messages go out from it. */
|
|
36
|
+
phoneNumber?: string;
|
|
37
|
+
/** Defaults to `twilio`. */
|
|
38
|
+
voiceEngine?: VoiceEngine;
|
|
39
|
+
/** The ElevenLabs integration that runs the calls when `voiceEngine` is `elevenlabs`. */
|
|
40
|
+
elevenLabsIntegrationId?: IntegrationId;
|
|
41
|
+
/** The OpenAI Voice integration that answers the calls when `voiceEngine` is `openai`. */
|
|
42
|
+
openAiVoiceIntegrationId?: IntegrationId;
|
|
43
|
+
/** OpenAI engine: the realtime model that talks on the call. Defaults to the integration's default model. */
|
|
44
|
+
voiceModel?: string;
|
|
45
|
+
/** Spoken as soon as a call is answered. Defaults to a short greeting in `language`, when one is known. */
|
|
46
|
+
welcomeGreeting?: string;
|
|
47
|
+
/**
|
|
48
|
+
* `phrase` (the default) speaks `welcomeGreeting` as soon as the call is answered; `agent` has the agent
|
|
49
|
+
* compose the opening line once the call connects, so it can look the caller up and greet a known caller by
|
|
50
|
+
* name, saying `welcomeGreeting` when there is nothing to personalize. Twilio and OpenAI engines; the
|
|
51
|
+
* ElevenLabs engine always speaks `welcomeGreeting`.
|
|
52
|
+
*/
|
|
53
|
+
greetingMode?: AiVoiceGreetingMode;
|
|
54
|
+
/** BCP-47 language of the call, e.g. `en-US` or `he-IL`. Defaults to `en-US`. */
|
|
55
|
+
language?: string;
|
|
56
|
+
/**
|
|
57
|
+
* How the call handles languages. `single` (the default) keeps the whole call in `language`; `selected` lets
|
|
58
|
+
* the caller switch between `language` and `additionalLanguages`; `any` follows the caller into any language
|
|
59
|
+
* ElevenLabs can switch to. ElevenLabs engine; the Twilio engine always stays in `language`.
|
|
60
|
+
*/
|
|
61
|
+
languageMode?: VoiceLanguageMode;
|
|
62
|
+
/** The languages the caller may switch to when `languageMode` is `selected`, as ISO codes (`en`, `es`). */
|
|
63
|
+
additionalLanguages?: Array<string>;
|
|
64
|
+
/** Voice of the engine: an ElevenLabs voice id, an OpenAI voice name, or a Twilio provider voice. Defaults to the engine's default. */
|
|
65
|
+
voice?: string;
|
|
66
|
+
/** Spoken when an answer takes more than a moment. ElevenLabs engine only; defaults to a phrase in `language`, when one is known. */
|
|
67
|
+
fillerMessage?: string;
|
|
68
|
+
/** Seconds of waiting for the answer before the filler is spoken. ElevenLabs engine only; defaults to 4. */
|
|
69
|
+
fillerAfterSeconds?: number;
|
|
70
|
+
/** Twilio engine: defaults to `relay`. */
|
|
71
|
+
voiceMode?: VoiceMode;
|
|
72
|
+
/** Twilio engine, `relay` mode: text-to-speech provider. Defaults to ElevenLabs. */
|
|
73
|
+
ttsProvider?: 'ElevenLabs' | 'Google' | 'Amazon';
|
|
74
|
+
/** Twilio engine, `relay` mode: speech-to-text provider. Defaults to Deepgram. */
|
|
75
|
+
transcriptionProvider?: 'Deepgram' | 'Google';
|
|
76
|
+
/** When true, the connector does not answer incoming SMS with the agent; handle {@link SMS_EVENT_TYPE} yourself. */
|
|
77
|
+
disableBuiltInSmsReply?: boolean;
|
|
78
|
+
/** Written by the connector after every save: whether the number is wired to the agent, and how. */
|
|
79
|
+
provisioning?: TwilioAgentProvisioning;
|
|
80
|
+
}
|
|
81
|
+
/** The outcome of wiring an agent's number up, written by the connector. */
|
|
82
|
+
export interface TwilioAgentProvisioning {
|
|
83
|
+
state: 'ready' | 'error';
|
|
84
|
+
/** What went wrong, when `state` is `error`. */
|
|
85
|
+
message?: string;
|
|
86
|
+
/** ISO timestamp of the last attempt. */
|
|
87
|
+
updatedAt: string;
|
|
88
|
+
/** The ElevenLabs side of the setup, when ElevenLabs runs the calls. */
|
|
89
|
+
elevenLabs?: ElevenLabsProvisionedIds;
|
|
90
|
+
/** The OpenAI side of the setup, when OpenAI answers the calls. */
|
|
91
|
+
openAi?: OpenAiVoiceSipTarget;
|
|
92
|
+
}
|
|
93
|
+
/** Where calls go for OpenAI to answer them, and where OpenAI announces them; mirrors the OpenAI Voice connector. */
|
|
94
|
+
export interface OpenAiVoiceSipTarget {
|
|
95
|
+
/** SIP URI of the OpenAI project. */
|
|
96
|
+
sipUri: string;
|
|
97
|
+
/** URL to register in the OpenAI project as its `realtime.call.incoming` webhook. */
|
|
98
|
+
webhookUrl: string;
|
|
99
|
+
}
|
|
100
|
+
/** What the ElevenLabs connector created for one agent's number. */
|
|
101
|
+
export interface ElevenLabsProvisionedIds {
|
|
102
|
+
/** ElevenLabs agent id (`agent_…`). */
|
|
103
|
+
agentId: string;
|
|
104
|
+
/** ElevenLabs id of the imported Twilio number. */
|
|
105
|
+
phoneNumberId: string;
|
|
106
|
+
/** ElevenLabs secret holding the Squid API key the ElevenLabs agent calls Squid with. */
|
|
107
|
+
squidApiKeySecretId: string;
|
|
108
|
+
}
|
|
109
|
+
/** The payload broadcast on {@link SMS_EVENT_TYPE}. */
|
|
110
|
+
export interface TwilioSmsEvent {
|
|
111
|
+
/** The Twilio integration that received the message. */
|
|
112
|
+
integrationId: IntegrationId;
|
|
113
|
+
/** The agent whose number received the message, when one is connected. */
|
|
114
|
+
agentId?: string;
|
|
115
|
+
/** Twilio message id (`SM…`). */
|
|
116
|
+
messageSid: string;
|
|
117
|
+
/** Sender phone number. */
|
|
118
|
+
from: string;
|
|
119
|
+
/** The Twilio number that received the message. */
|
|
120
|
+
to: string;
|
|
121
|
+
/** Message text. */
|
|
122
|
+
body: string;
|
|
123
|
+
}
|
|
124
|
+
/** A phone call handled by the connector, stored in the `twilio_calls` collection under its call id. */
|
|
125
|
+
export interface TwilioCallRecord {
|
|
126
|
+
callSid: CallSid;
|
|
127
|
+
integrationId: IntegrationId;
|
|
128
|
+
/** The agent on the call. */
|
|
129
|
+
agentId?: string;
|
|
130
|
+
direction: 'inbound' | 'outbound';
|
|
131
|
+
from: string;
|
|
132
|
+
to: string;
|
|
133
|
+
/** Last Twilio call status: `in-progress`, `completed`, `busy`, `failed`, `no-answer`, `canceled`. */
|
|
134
|
+
status: string;
|
|
135
|
+
/** Defaults to `twilio`. */
|
|
136
|
+
voiceEngine?: VoiceEngine;
|
|
137
|
+
voiceMode: VoiceMode;
|
|
138
|
+
startedAt: Date;
|
|
139
|
+
endedAt?: Date;
|
|
140
|
+
/** Seconds, once the call completed. */
|
|
141
|
+
durationSeconds?: number;
|
|
142
|
+
/** Extra instructions for the agent on this call, set when the call was placed. */
|
|
143
|
+
instructions?: string;
|
|
144
|
+
/** Voice session id in Squid (relay mode). */
|
|
145
|
+
sessionId?: string;
|
|
146
|
+
/** Consecutive turns without caller speech (gather mode); the call ends after two. */
|
|
147
|
+
silentTurns?: number;
|
|
148
|
+
}
|
|
149
|
+
/** One turn of a call, stored in the `twilio_call_transcripts` collection. */
|
|
150
|
+
export interface TwilioCallTranscriptEntry {
|
|
151
|
+
callSid: CallSid;
|
|
152
|
+
role: 'user' | 'agent';
|
|
153
|
+
text: string;
|
|
154
|
+
at: Date;
|
|
155
|
+
}
|
|
156
|
+
/** Request for the `sendSms` executable. */
|
|
157
|
+
export interface SendTwilioSmsRequest {
|
|
158
|
+
integrationId: IntegrationId;
|
|
159
|
+
/** Recipient phone number in E.164 format. */
|
|
160
|
+
to: string;
|
|
161
|
+
/** Message text. */
|
|
162
|
+
body: string;
|
|
163
|
+
/** Sender number; defaults to the number of `agentId`, else of the first agent connected to the integration. */
|
|
164
|
+
from?: string;
|
|
165
|
+
/** The agent whose number sends the message. */
|
|
166
|
+
agentId?: string;
|
|
167
|
+
}
|
|
168
|
+
/** Response of the `sendSms` executable. */
|
|
169
|
+
export interface SendTwilioSmsResponse {
|
|
170
|
+
messageSid: string;
|
|
171
|
+
status: string;
|
|
172
|
+
}
|
|
173
|
+
/** Request for the `placeCall` executable. */
|
|
174
|
+
export interface PlaceTwilioCallRequest {
|
|
175
|
+
integrationId: IntegrationId;
|
|
176
|
+
/** Phone number to call, in E.164 format. */
|
|
177
|
+
to: string;
|
|
178
|
+
/** The agent that talks once the call is answered; the call is placed from its number. */
|
|
179
|
+
agentId: string;
|
|
180
|
+
/** Caller number override; Twilio engine only. */
|
|
181
|
+
from?: string;
|
|
182
|
+
/** Extra instructions for the agent on this call, e.g. the purpose of the call. Twilio engine only. */
|
|
183
|
+
instructions?: string;
|
|
184
|
+
}
|
|
185
|
+
/** Response of the `placeCall` executable. */
|
|
186
|
+
export interface PlaceTwilioCallResponse {
|
|
187
|
+
callSid: CallSid;
|
|
188
|
+
}
|
|
189
|
+
/** Request for the `getCallTranscript` executable. */
|
|
190
|
+
export interface GetTwilioCallTranscriptRequest {
|
|
191
|
+
integrationId: IntegrationId;
|
|
192
|
+
callSid: CallSid;
|
|
193
|
+
}
|
|
194
|
+
/** Response of the `getCallTranscript` executable. */
|
|
195
|
+
export interface GetTwilioCallTranscriptResponse {
|
|
196
|
+
call: TwilioCallRecord | undefined;
|
|
197
|
+
/** Turns in chronological order. */
|
|
198
|
+
transcript: Array<TwilioCallTranscriptEntry>;
|
|
199
|
+
}
|
|
200
|
+
/** Request for the `twilioListPhoneNumbers` executable. */
|
|
201
|
+
export interface ListTwilioPhoneNumbersRequest {
|
|
202
|
+
integrationId: IntegrationId;
|
|
203
|
+
}
|
|
204
|
+
/** A phone number of the Twilio account. */
|
|
205
|
+
export interface TwilioPhoneNumber {
|
|
206
|
+
/** E.164. */
|
|
207
|
+
phoneNumber: string;
|
|
208
|
+
friendlyName: string;
|
|
209
|
+
/** The agent the number already rings, when one is connected with it. */
|
|
210
|
+
usedByAgentId?: string;
|
|
211
|
+
}
|
|
212
|
+
/** Response of the `twilioListPhoneNumbers` executable. */
|
|
213
|
+
export interface ListTwilioPhoneNumbersResponse {
|
|
214
|
+
phoneNumbers: Array<TwilioPhoneNumber>;
|
|
215
|
+
}
|
|
216
|
+
/** Request for the `twilioProvisionAgent` executable, which wires an agent's number up again. */
|
|
217
|
+
export interface ProvisionTwilioAgentRequest {
|
|
218
|
+
integrationId: IntegrationId;
|
|
219
|
+
agentId: string;
|
|
220
|
+
}
|
|
221
|
+
/** Response of the `twilioProvisionAgent` executable. */
|
|
222
|
+
export interface ProvisionTwilioAgentResponse {
|
|
223
|
+
provisioning: TwilioAgentProvisioning;
|
|
224
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { AiAgentTwilioIntegrationOptions, GetTwilioCallTranscriptRequest, GetTwilioCallTranscriptResponse, ListTwilioPhoneNumbersRequest, ListTwilioPhoneNumbersResponse, PlaceTwilioCallRequest, PlaceTwilioCallResponse, ProvisionTwilioAgentRequest, ProvisionTwilioAgentResponse, SMS_EVENT_TYPE, SendTwilioSmsRequest, SendTwilioSmsResponse, TwilioAgentProvisioning, TwilioCallRecord, TwilioCallTranscriptEntry, TwilioPhoneNumber, TwilioSmsEvent, VoiceEngine, VoiceMode, } from '../../common/src/twilio-types';
|
|
2
|
+
export * from './twilio-client';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Squid } from '@squidcloud/client';
|
|
2
|
+
import { GetTwilioCallTranscriptRequest, GetTwilioCallTranscriptResponse, ListTwilioPhoneNumbersResponse, PlaceTwilioCallRequest, PlaceTwilioCallResponse, ProvisionTwilioAgentRequest, ProvisionTwilioAgentResponse, SendTwilioSmsRequest, SendTwilioSmsResponse } from '../../common/src/twilio-types';
|
|
3
|
+
/** Client of the Twilio connector for one integration; every call needs an app API key. */
|
|
4
|
+
export declare class SquidTwilioClient {
|
|
5
|
+
private readonly squid;
|
|
6
|
+
private readonly integrationId;
|
|
7
|
+
constructor(squid: Squid, integrationId: string);
|
|
8
|
+
/** Sends an SMS from an agent's number. */
|
|
9
|
+
sendSms(request: Omit<SendTwilioSmsRequest, 'integrationId'>): Promise<SendTwilioSmsResponse>;
|
|
10
|
+
/** Places an outbound call that connects whoever answers to the agent. */
|
|
11
|
+
placeCall(request: Omit<PlaceTwilioCallRequest, 'integrationId'>): Promise<PlaceTwilioCallResponse>;
|
|
12
|
+
/** A call's record and transcript. */
|
|
13
|
+
getCallTranscript(request: Omit<GetTwilioCallTranscriptRequest, 'integrationId'>): Promise<GetTwilioCallTranscriptResponse>;
|
|
14
|
+
/** The account's phone numbers, each with the agent it already rings, if any. */
|
|
15
|
+
listPhoneNumbers(): Promise<ListTwilioPhoneNumbersResponse>;
|
|
16
|
+
/** Wires an agent's number up again and returns the outcome; saving the agent's connection does this on its own. */
|
|
17
|
+
provisionAgent(request: Omit<ProvisionTwilioAgentRequest, 'integrationId'>): Promise<ProvisionTwilioAgentResponse>;
|
|
18
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";const e={d:(t,i)=>{if(Array.isArray(i))for(var n=0;n<i.length;){var r=i[n++],o=i[n++];e.o(t,r)?0===o&&n++:0===o?Object.defineProperty(t,r,{enumerable:!0,value:i[n++]}):Object.defineProperty(t,r,{enumerable:!0,get:o})}else for(var r in i)e.o(i,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:i[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let t={};e.r(t),e.d(t,{SMS_EVENT_TYPE:()=>i,SquidTwilioClient:()=>n});const i="twilio-sms-event";class n{constructor(e,t){this.squid=e,this.integrationId=t}async sendSms(e){return this.squid.executeFunction("sendSms",{...e,integrationId:this.integrationId})}async placeCall(e){return this.squid.executeFunction("placeCall",{...e,integrationId:this.integrationId})}async getCallTranscript(e){return this.squid.executeFunction("getCallTranscript",{...e,integrationId:this.integrationId})}async listPhoneNumbers(){return this.squid.executeFunction("twilioListPhoneNumbers",{integrationId:this.integrationId})}async provisionAgent(e){return this.squid.executeFunction("twilioProvisionAgent",{...e,integrationId:this.integrationId})}}const r=exports;for(var o in t)r[o]=t[o];t.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** A language a phone call can start in: a BCP-47 tag the speech providers accept, and its display name. */
|
|
2
|
+
export interface VoiceLocale {
|
|
3
|
+
tag: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
/** ISO codes of every language with a display name; the languages an engine that speaks anything can switch to. */
|
|
7
|
+
export declare const VOICE_LANGUAGE_CODES: ReadonlyArray<string>;
|
|
8
|
+
/** Locales a call can start in; the tag drives Twilio speech, and its language part the ElevenLabs agent. */
|
|
9
|
+
export declare const VOICE_LOCALES: ReadonlyArray<VoiceLocale>;
|
|
10
|
+
/** The ISO codes ElevenLabs can switch a call to mid-call; any language can still be the one a call starts in. */
|
|
11
|
+
export declare const ELEVENLABS_SWITCH_LANGUAGES: ReadonlyArray<string>;
|
|
12
|
+
/**
|
|
13
|
+
* How a call handles languages: `single` keeps the whole call in its language, `selected` lets the caller
|
|
14
|
+
* switch between it and a chosen set, `any` follows the caller into any language the platform can switch to.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VOICE_LANGUAGE_MODES: readonly ["single", "selected", "any"];
|
|
17
|
+
/** One of {@link VOICE_LANGUAGE_MODES}. */
|
|
18
|
+
export type VoiceLanguageMode = (typeof VOICE_LANGUAGE_MODES)[number];
|
|
19
|
+
/** The display name of a language code or tag: `he-IL` and `he` give `Hebrew`; an unknown code is returned as is. */
|
|
20
|
+
export declare function voiceLanguageName(code: string): string;
|
|
21
|
+
/** The name with the code an LLM must pass: `he` gives `Hebrew (he)`; an unknown code stays bare. */
|
|
22
|
+
export declare function voiceLanguageLabel(code: string): string;
|