-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenapi.yaml
More file actions
378 lines (354 loc) · 11.3 KB
/
openapi.yaml
File metadata and controls
378 lines (354 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
openapi: 3.0.3
info:
title: SIP AI Assistant API
description: |
REST API for initiating outbound notification calls with optional response collection.
## Overview
This API allows you to:
- Make outbound calls to SIP extensions
- Play pre-defined messages
- Optionally collect user responses via voice
- Receive results via webhook callback
## Authentication
Currently no authentication is required. Secure access via network policies or API gateway.
## Webhook Callbacks
When `callback_url` is provided, results are POSTed after call completion.
Webhook is **required** when using choice collection.
version: 1.0.0
contact:
name: SIP AI Assistant
license:
name: MIT
servers:
- url: http://localhost:8080
description: Local development server
paths:
/health:
get:
summary: Health Check
description: Check if the service is healthy and SIP is registered
operationId: healthCheck
tags:
- System
responses:
'200':
description: Service health status
content:
application/json:
schema:
$ref: '#/components/schemas/HealthResponse'
example:
status: healthy
sip_registered: true
/call:
post:
summary: Initiate Outbound Call
description: |
Initiate an outbound notification call to a SIP extension.
The call is made asynchronously. The endpoint returns immediately with a call ID,
and the actual call happens in the background.
If `callback_url` is provided, a webhook POST is sent when the call completes.
**Note:** `callback_url` is required when using `choice` collection.
operationId: initiateCall
tags:
- Calls
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/OutboundCallRequest'
examples:
simple_notification:
summary: Simple notification (no webhook)
value:
message: "Hello, this is a reminder about your appointment tomorrow at 2pm."
extension: "1001"
ring_timeout: 30
with_webhook:
summary: Notification with webhook
value:
message: "Your package has been delivered."
extension: "1001"
callback_url: "https://example.com/webhook"
with_choice:
summary: Choice collection (webhook required)
value:
message: "Hello, this is a reminder about your appointment tomorrow at 2pm."
extension: "1001"
callback_url: "https://example.com/webhook"
ring_timeout: 30
choice:
prompt: "Would you like to confirm or cancel? Say yes to confirm or no to cancel."
options:
- value: "confirmed"
synonyms: ["yes", "yeah", "yep", "confirm", "okay", "sure"]
- value: "cancelled"
synonyms: ["no", "nope", "cancel", "nevermind"]
timeout_seconds: 15
repeat_count: 2
responses:
'200':
description: Call initiated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/OutboundCallResponse'
example:
call_id: "out-1234567890-1"
status: "queued"
message: "Call initiated"
'400':
description: Invalid request (e.g., choice without callback_url)
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
detail: "callback_url is required when choice is specified"
'500':
description: Server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/call/{call_id}:
get:
summary: Get Call Status
description: Check the status of a pending outbound call
operationId: getCallStatus
tags:
- Calls
parameters:
- name: call_id
in: path
required: true
description: The call ID returned from POST /call
schema:
type: string
example: "out-1234567890-1"
responses:
'200':
description: Call status
content:
application/json:
schema:
$ref: '#/components/schemas/CallStatusResponse'
examples:
in_progress:
summary: Call in progress
value:
call_id: "out-1234567890-1"
status: "in_progress"
extension: "1001"
not_found:
summary: Call not found (completed or invalid)
value:
call_id: "out-1234567890-1"
status: "not_found"
components:
schemas:
HealthResponse:
type: object
properties:
status:
type: string
enum: [healthy, unhealthy]
description: Service health status
sip_registered:
type: boolean
description: Whether SIP registration is active
OutboundCallRequest:
type: object
required:
- message
- extension
properties:
message:
type: string
description: Message to speak to the recipient
example: "Hello, this is a reminder about your appointment."
extension:
type: string
description: SIP extension, phone number, or full SIP URI
example: "1001"
callback_url:
type: string
format: uri
nullable: true
description: |
Webhook URL to POST results to when call completes.
Required when using `choice` collection.
example: "https://example.com/webhook"
ring_timeout:
type: integer
default: 30
minimum: 5
maximum: 120
description: Seconds to wait for call to be answered
choice:
$ref: '#/components/schemas/ChoicePrompt'
call_id:
type: string
nullable: true
description: Optional caller-provided ID for tracking
example: "my-custom-id-123"
ChoicePrompt:
type: object
required:
- prompt
- options
description: Configuration for collecting user voice response
properties:
prompt:
type: string
description: Question to ask the user
example: "Would you like to confirm or cancel?"
options:
type: array
items:
$ref: '#/components/schemas/ChoiceOption'
minItems: 1
description: List of valid choice options
timeout_seconds:
type: integer
default: 30
minimum: 5
maximum: 60
description: Seconds to wait for user response
repeat_count:
type: integer
default: 2
minimum: 1
maximum: 5
description: Times to repeat prompt if no response detected
ChoiceOption:
type: object
required:
- value
properties:
value:
type: string
description: Value returned in webhook if this option is selected
example: "confirmed"
synonyms:
type: array
items:
type: string
default: []
description: Alternative phrases that map to this choice
example: ["yes", "yeah", "yep", "confirm"]
OutboundCallResponse:
type: object
properties:
call_id:
type: string
description: Unique identifier for tracking the call
example: "out-1234567890-1"
status:
$ref: '#/components/schemas/CallStatus'
message:
type: string
description: Human-readable status message
example: "Call initiated"
CallStatusResponse:
type: object
properties:
call_id:
type: string
status:
type: string
enum: [in_progress, not_found]
extension:
type: string
description: Present only if status is in_progress
CallStatus:
type: string
enum:
- queued
- ringing
- answered
- completed
- no_answer
- failed
- busy
description: |
- `queued` - Call is queued for processing
- `ringing` - Call is ringing
- `answered` - Call was answered
- `completed` - Call completed successfully
- `no_answer` - Call was not answered within ring timeout
- `failed` - Call failed to connect
- `busy` - Extension was busy
WebhookPayload:
type: object
description: Payload POSTed to callback_url when call completes
properties:
call_id:
type: string
description: Call identifier
example: "out-1234567890-1"
status:
$ref: '#/components/schemas/CallStatus'
extension:
type: string
description: Extension that was called
example: "1001"
duration_seconds:
type: number
format: float
description: Total call duration in seconds
example: 45.2
message_played:
type: boolean
description: Whether the message was successfully played
choice_response:
type: string
nullable: true
description: Matched choice value (if choice was configured)
example: "confirmed"
choice_raw_text:
type: string
nullable: true
description: Raw transcription of user's response
example: "yes I confirm"
error:
type: string
nullable: true
description: Error message if call failed
example:
call_id: "out-1234567890-1"
status: "completed"
extension: "1001"
duration_seconds: 45.2
message_played: true
choice_response: "confirmed"
choice_raw_text: "yes I confirm"
error: null
ErrorResponse:
type: object
properties:
detail:
type: string
description: Error description
example: "callback_url is required when choice is specified"
callbacks:
callComplete:
'{$request.body#/callback_url}':
post:
summary: Call Completion Webhook
description: Sent to callback_url when the outbound call completes
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/WebhookPayload'
responses:
'200':
description: Webhook received successfully
tags:
- name: System
description: Health and status endpoints
- name: Calls
description: Outbound call management