@fonoster/ctl 0.4.7 → 0.7.37

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.
Files changed (112) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +349 -606
  3. package/bin/run.js +7 -0
  4. package/dist/commands/workspace/login.d.ts +6 -0
  5. package/dist/commands/workspace/login.js +80 -0
  6. package/dist/config/addWorkspace.d.ts +3 -0
  7. package/dist/config/addWorkspace.js +10 -0
  8. package/dist/config/getConfig.d.ts +3 -0
  9. package/dist/{commands/projects/delete.js → config/getConfig.js} +10 -14
  10. package/dist/config/getCurrentWorkspace.d.ts +3 -0
  11. package/dist/config/getCurrentWorkspace.js +10 -0
  12. package/dist/config/index.d.ts +7 -0
  13. package/dist/config/index.js +41 -0
  14. package/dist/config/removeWorkspace.d.ts +3 -0
  15. package/dist/config/removeWorkspace.js +6 -0
  16. package/dist/config/saveConfig.d.ts +3 -0
  17. package/dist/{commands/feedback.js → config/saveConfig.js} +11 -12
  18. package/dist/config/setCurrentWorkspace.d.ts +3 -0
  19. package/dist/config/setCurrentWorkspace.js +11 -0
  20. package/dist/config/types.d.ts +4 -0
  21. package/dist/config/types.js +2 -0
  22. package/dist/config/validations.d.ts +24 -0
  23. package/dist/{index.js → config/validations.js} +12 -4
  24. package/dist/constants.d.ts +3 -0
  25. package/dist/{utils.js → constants.js} +7 -10
  26. package/package.json +29 -64
  27. package/bin/run +0 -5
  28. package/bin/run.cmd +0 -3
  29. package/dist/base/delete.d.ts +0 -9
  30. package/dist/base/delete.js +0 -50
  31. package/dist/commands/agents/create.d.ts +0 -6
  32. package/dist/commands/agents/create.js +0 -112
  33. package/dist/commands/agents/delete.d.ts +0 -9
  34. package/dist/commands/agents/delete.js +0 -39
  35. package/dist/commands/agents/get.d.ts +0 -9
  36. package/dist/commands/agents/get.js +0 -60
  37. package/dist/commands/agents/list.d.ts +0 -10
  38. package/dist/commands/agents/list.js +0 -92
  39. package/dist/commands/agents/update.d.ts +0 -9
  40. package/dist/commands/agents/update.js +0 -90
  41. package/dist/commands/apps/create.d.ts +0 -6
  42. package/dist/commands/apps/create.js +0 -213
  43. package/dist/commands/apps/delete.d.ts +0 -9
  44. package/dist/commands/apps/delete.js +0 -54
  45. package/dist/commands/apps/list.d.ts +0 -10
  46. package/dist/commands/apps/list.js +0 -107
  47. package/dist/commands/apps/update.d.ts +0 -9
  48. package/dist/commands/apps/update.js +0 -235
  49. package/dist/commands/auth/login.d.ts +0 -6
  50. package/dist/commands/auth/login.js +0 -84
  51. package/dist/commands/auth/logout.d.ts +0 -6
  52. package/dist/commands/auth/logout.js +0 -46
  53. package/dist/commands/bug.d.ts +0 -6
  54. package/dist/commands/bug.js +0 -33
  55. package/dist/commands/domains/create.d.ts +0 -6
  56. package/dist/commands/domains/create.js +0 -130
  57. package/dist/commands/domains/delete.d.ts +0 -9
  58. package/dist/commands/domains/delete.js +0 -49
  59. package/dist/commands/domains/get.d.ts +0 -9
  60. package/dist/commands/domains/get.js +0 -63
  61. package/dist/commands/domains/list.d.ts +0 -10
  62. package/dist/commands/domains/list.js +0 -95
  63. package/dist/commands/domains/update.d.ts +0 -9
  64. package/dist/commands/domains/update.js +0 -124
  65. package/dist/commands/feedback.d.ts +0 -6
  66. package/dist/commands/numbers/create.d.ts +0 -6
  67. package/dist/commands/numbers/create.js +0 -117
  68. package/dist/commands/numbers/delete.d.ts +0 -9
  69. package/dist/commands/numbers/delete.js +0 -49
  70. package/dist/commands/numbers/get.d.ts +0 -9
  71. package/dist/commands/numbers/get.js +0 -59
  72. package/dist/commands/numbers/list.d.ts +0 -10
  73. package/dist/commands/numbers/list.js +0 -100
  74. package/dist/commands/numbers/update.d.ts +0 -9
  75. package/dist/commands/numbers/update.js +0 -104
  76. package/dist/commands/projects/create.d.ts +0 -6
  77. package/dist/commands/projects/create.js +0 -75
  78. package/dist/commands/projects/delete.d.ts +0 -9
  79. package/dist/commands/projects/get.d.ts +0 -9
  80. package/dist/commands/projects/get.js +0 -55
  81. package/dist/commands/projects/list.d.ts +0 -6
  82. package/dist/commands/projects/list.js +0 -50
  83. package/dist/commands/projects/renew.d.ts +0 -9
  84. package/dist/commands/projects/renew.js +0 -47
  85. package/dist/commands/projects/use.d.ts +0 -9
  86. package/dist/commands/projects/use.js +0 -60
  87. package/dist/commands/providers/create.d.ts +0 -6
  88. package/dist/commands/providers/create.js +0 -114
  89. package/dist/commands/providers/delete.d.ts +0 -9
  90. package/dist/commands/providers/delete.js +0 -49
  91. package/dist/commands/providers/get.d.ts +0 -9
  92. package/dist/commands/providers/get.js +0 -61
  93. package/dist/commands/providers/list.d.ts +0 -10
  94. package/dist/commands/providers/list.js +0 -98
  95. package/dist/commands/providers/update.d.ts +0 -9
  96. package/dist/commands/providers/update.js +0 -113
  97. package/dist/commands/secrets/create.d.ts +0 -14
  98. package/dist/commands/secrets/create.js +0 -69
  99. package/dist/commands/secrets/delete.d.ts +0 -10
  100. package/dist/commands/secrets/delete.js +0 -57
  101. package/dist/commands/secrets/list.d.ts +0 -10
  102. package/dist/commands/secrets/list.js +0 -71
  103. package/dist/config.d.ts +0 -29
  104. package/dist/config.js +0 -73
  105. package/dist/data/voices.d.ts +0 -1
  106. package/dist/data/voices.js +0 -337
  107. package/dist/decorators/project_guard.d.ts +0 -9
  108. package/dist/decorators/project_guard.js +0 -44
  109. package/dist/help.d.ts +0 -6
  110. package/dist/help.js +0 -47
  111. package/dist/index.d.ts +0 -1
  112. package/dist/utils.d.ts +0 -1
package/README.md CHANGED
@@ -1,676 +1,419 @@
1
- # ctl
1
+ voice
2
+ =================
2
3
 
3
- Command-Line for for Fonoster
4
+ [![Voice](https://img.shields.io/badge/voice-api-brightgreen.svg)](https://fonoster.com)
5
+ [![Version](https://img.shields.io/npm/v/@fonoster/voice.svg)](https://npmjs.org/package/@fonoster/voice)
6
+ [![Downloads/week](https://img.shields.io/npm/dw/@fonoster/voice.svg)](https://npmjs.org/package/@fonoster/voice)
7
+ [![License](https://img.shields.io/npm/l/@fonoster/voice.svg)](https://github.com/fonoster/fonoster/blob/main/package.json)
4
8
 
5
- [![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
6
- [![Version](https://img.shields.io/npm/v/ctl.svg)](https://npmjs.org/package/ctl)
7
- [![Downloads/week](https://img.shields.io/npm/dw/ctl.svg)](https://npmjs.org/package/ctl)
8
- [![License](https://img.shields.io/npm/l/ctl.svg)](https://github.com/fonoster/fonoster/blob/main/package.json)
9
+ The Voice module is a library for creating voice applications using the Fonoster API. It provides a simple way to create voice applications that can interact with the calling party using DTMF or speech recognition combined with simple verbs.
9
10
 
10
- <!-- toc -->
11
- * [ctl](#ctl)
12
- * [Usage](#usage)
13
- * [Commands](#commands)
14
- <!-- tocstop -->
11
+ * [Installation](#installation)
12
+ * [Example](#example)
13
+ * [Voice Response](#VoiceResponse)
15
14
 
16
- # Usage
15
+ ## Installation
17
16
 
18
- <!-- usage -->
19
17
  ```sh-session
20
- $ npm install -g @fonoster/ctl
21
- $ fonoster COMMAND
22
- running command...
23
- $ fonoster (-v|--version|version)
24
- @fonoster/ctl/0.4.0 darwin-x64 node-v16.18.1
25
- $ fonoster --help [COMMAND]
26
- USAGE
27
- $ fonoster COMMAND
28
- ...
18
+ $ npm install --save @fonoster/voice
29
19
  ```
30
- <!-- usagestop -->
31
-
32
- # Commands
33
-
34
- <!-- commands -->
35
- * [`fonoster agents:create`](#fonoster-agentscreate)
36
- * [`fonoster agents:delete [REF]`](#fonoster-agentsdelete-ref)
37
- * [`fonoster agents:get [REF]`](#fonoster-agentsget-ref)
38
- * [`fonoster agents:list`](#fonoster-agentslist)
39
- * [`fonoster agents:update [REF]`](#fonoster-agentsupdate-ref)
40
- * [`fonoster auth:login`](#fonoster-authlogin)
41
- * [`fonoster auth:logout`](#fonoster-authlogout)
42
- * [`fonoster bug`](#fonoster-bug)
43
- * [`fonoster domains:create`](#fonoster-domainscreate)
44
- * [`fonoster domains:delete [REF]`](#fonoster-domainsdelete-ref)
45
- * [`fonoster domains:get [REF]`](#fonoster-domainsget-ref)
46
- * [`fonoster domains:list`](#fonoster-domainslist)
47
- * [`fonoster domains:update [REF]`](#fonoster-domainsupdate-ref)
48
- * [`fonoster feedback`](#fonoster-feedback)
49
- * [`fonoster help [COMMAND]`](#fonoster-help-command)
50
- * [`fonoster numbers:create`](#fonoster-numberscreate)
51
- * [`fonoster numbers:delete [REF]`](#fonoster-numbersdelete-ref)
52
- * [`fonoster numbers:get [REF]`](#fonoster-numbersget-ref)
53
- * [`fonoster numbers:list`](#fonoster-numberslist)
54
- * [`fonoster numbers:update [REF]`](#fonoster-numbersupdate-ref)
55
- * [`fonoster plugins`](#fonoster-plugins)
56
- * [`fonoster plugins:inspect PLUGIN...`](#fonoster-pluginsinspect-plugin)
57
- * [`fonoster plugins:install PLUGIN...`](#fonoster-pluginsinstall-plugin)
58
- * [`fonoster plugins:link PLUGIN`](#fonoster-pluginslink-plugin)
59
- * [`fonoster plugins:uninstall PLUGIN...`](#fonoster-pluginsuninstall-plugin)
60
- * [`fonoster plugins:update`](#fonoster-pluginsupdate)
61
- * [`fonoster projects:create`](#fonoster-projectscreate)
62
- * [`fonoster projects:delete [REF]`](#fonoster-projectsdelete-ref)
63
- * [`fonoster projects:get [REF]`](#fonoster-projectsget-ref)
64
- * [`fonoster projects:list`](#fonoster-projectslist)
65
- * [`fonoster projects:renew [REF]`](#fonoster-projectsrenew-ref)
66
- * [`fonoster projects:use [REF]`](#fonoster-projectsuse-ref)
67
- * [`fonoster providers:create`](#fonoster-providerscreate)
68
- * [`fonoster providers:delete [REF]`](#fonoster-providersdelete-ref)
69
- * [`fonoster providers:get [REF]`](#fonoster-providersget-ref)
70
- * [`fonoster providers:list`](#fonoster-providerslist)
71
- * [`fonoster providers:update [REF]`](#fonoster-providersupdate-ref)
72
-
73
- ## `fonoster agents:create`
74
-
75
- create a new Fonoster Agent
76
20
 
77
- ```
78
- USAGE
79
- $ fonoster agents:create
80
-
81
- DESCRIPTION
82
- ...
83
- Create a new Fonoster Agent
84
- ```
85
-
86
- _See code: [dist/commands/agents/create.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/agents/create.js)_
87
-
88
- ## `fonoster agents:delete [REF]`
89
-
90
- delete a Fonoster Agent
91
-
92
- ```
93
- USAGE
94
- $ fonoster agents:delete [REF]
95
-
96
- ALIASES
97
- $ fonoster agents:del
98
- $ fonoster agents:rm
99
- ```
100
-
101
- _See code: [dist/commands/agents/delete.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/agents/delete.js)_
102
-
103
- ## `fonoster agents:get [REF]`
104
-
105
- get a Fonoster Agent
106
-
107
- ```
108
- USAGE
109
- $ fonoster agents:get [REF]
110
- ```
111
-
112
- _See code: [dist/commands/agents/get.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/agents/get.js)_
113
-
114
- ## `fonoster agents:list`
115
-
116
- list all Fonoster Agents you have access to
117
-
118
- ```
119
- USAGE
120
- $ fonoster agents:list
121
-
122
- OPTIONS
123
- -s, --size=size [default: 25] agent of result per page
124
-
125
- DESCRIPTION
126
- ...
127
- List all Fonoster Agents you have access to
128
-
129
- ALIASES
130
- $ fonoster agents:ls
131
- ```
132
-
133
- _See code: [dist/commands/agents/list.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/agents/list.js)_
134
-
135
- ## `fonoster agents:update [REF]`
136
-
137
- update a Fonoster Agent
138
-
139
- ```
140
- USAGE
141
- $ fonoster agents:update [REF]
142
-
143
- DESCRIPTION
144
- ...
145
- Update a Fonoster Agent
146
- ```
147
-
148
- _See code: [dist/commands/agents/update.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/agents/update.js)_
149
-
150
- ## `fonoster auth:login`
151
-
152
- log in to a Fonoster deployment
153
-
154
- ```
155
- USAGE
156
- $ fonoster auth:login
157
- ```
158
-
159
- _See code: [dist/commands/auth/login.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/auth/login.js)_
160
-
161
- ## `fonoster auth:logout`
162
-
163
- log out from a fonoster deployment
164
-
165
- ```
166
- USAGE
167
- $ fonoster auth:logout
168
- ```
169
-
170
- _See code: [dist/commands/auth/logout.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/auth/logout.js)_
171
-
172
- ## `fonoster bug`
173
-
174
- start a bug report 🐞
175
-
176
- ```
177
- USAGE
178
- $ fonoster bug
179
-
180
- DESCRIPTION
181
- ...
182
- Opens github issues with a predefine bug template
183
- ```
184
-
185
- _See code: [dist/commands/bug.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/bug.js)_
186
-
187
- ## `fonoster domains:create`
188
-
189
- create a new Fonoster Domain
190
-
191
- ```
192
- USAGE
193
- $ fonoster domains:create
194
-
195
- DESCRIPTION
196
- ...
197
- Create a new Fonoster Domain
198
- ```
199
-
200
- _See code: [dist/commands/domains/create.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/domains/create.js)_
201
-
202
- ## `fonoster domains:delete [REF]`
203
-
204
- delete a Fonoster Domain
205
-
206
- ```
207
- USAGE
208
- $ fonoster domains:delete [REF]
209
-
210
- ALIASES
211
- $ fonoster domains:del
212
- $ fonoster domains:rm
213
- ```
214
-
215
- _See code: [dist/commands/domains/delete.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/domains/delete.js)_
216
-
217
- ## `fonoster domains:get [REF]`
218
-
219
- get a Fonoster Domain
220
-
221
- ```
222
- USAGE
223
- $ fonoster domains:get [REF]
224
- ```
225
-
226
- _See code: [dist/commands/domains/get.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/domains/get.js)_
227
-
228
- ## `fonoster domains:list`
229
-
230
- list all Fonoster Domains you have access to
231
-
232
- ```
233
- USAGE
234
- $ fonoster domains:list
235
-
236
- OPTIONS
237
- -s, --size=size [default: 25] number of result per page
238
-
239
- DESCRIPTION
240
- ...
241
- List all Fonoster Domains you have access to
242
-
243
- ALIASES
244
- $ fonoster domains:ls
245
- ```
246
-
247
- _See code: [dist/commands/domains/list.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/domains/list.js)_
248
-
249
- ## `fonoster domains:update [REF]`
250
-
251
- update a Fonoster Domain
252
-
253
- ```
254
- USAGE
255
- $ fonoster domains:update [REF]
256
-
257
- DESCRIPTION
258
- ...
259
- Update a Fonoster Domain
260
- ```
261
-
262
- _See code: [dist/commands/domains/update.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/domains/update.js)_
263
-
264
- ## `fonoster feedback`
265
-
266
- let us know how we're doing
267
-
268
- ```
269
- USAGE
270
- $ fonoster feedback
271
-
272
- DESCRIPTION
273
- ...
274
- Help us improve by providing some feedback
275
- ```
276
-
277
- _See code: [dist/commands/feedback.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/feedback.js)_
278
-
279
- ## `fonoster help [COMMAND]`
280
-
281
- display help for fonoster
282
-
283
- ```
284
- USAGE
285
- $ fonoster help [COMMAND]
286
-
287
- ARGUMENTS
288
- COMMAND command to show help for
289
-
290
- OPTIONS
291
- --all see all commands in CLI
292
- ```
293
-
294
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.3.1/src/commands/help.ts)_
295
-
296
- ## `fonoster numbers:create`
297
-
298
- create a new Fonoster Number
299
-
300
- ```
301
- USAGE
302
- $ fonoster numbers:create
303
-
304
- DESCRIPTION
305
- ...
306
- Create a new Fonoster Number
307
- ```
308
-
309
- _See code: [dist/commands/numbers/create.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/numbers/create.js)_
310
-
311
- ## `fonoster numbers:delete [REF]`
312
-
313
- delete a Fonoster Number
314
-
315
- ```
316
- USAGE
317
- $ fonoster numbers:delete [REF]
318
-
319
- ALIASES
320
- $ fonoster numbers:del
321
- $ fonoster numbers:rm
322
- ```
323
-
324
- _See code: [dist/commands/numbers/delete.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/numbers/delete.js)_
325
-
326
- ## `fonoster numbers:get [REF]`
327
-
328
- get a Fonoster Number
329
-
330
- ```
331
- USAGE
332
- $ fonoster numbers:get [REF]
333
- ```
334
-
335
- _See code: [dist/commands/numbers/get.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/numbers/get.js)_
336
-
337
- ## `fonoster numbers:list`
338
-
339
- list all Fonoster Numbers you have access to
340
-
341
- ```
342
- USAGE
343
- $ fonoster numbers:list
344
-
345
- OPTIONS
346
- -s, --size=size [default: 25] number of result per page
347
-
348
- DESCRIPTION
349
- ...
350
- List all Fonoster Numbers you have access to
351
-
352
- ALIASES
353
- $ fonoster numbers:ls
354
- ```
355
-
356
- _See code: [dist/commands/numbers/list.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/numbers/list.js)_
357
-
358
- ## `fonoster numbers:update [REF]`
359
-
360
- update a Fonoster Number
361
-
362
- ```
363
- USAGE
364
- $ fonoster numbers:update [REF]
365
-
366
- DESCRIPTION
367
- ...
368
- Update a Fonoster Number
369
- ```
370
-
371
- _See code: [dist/commands/numbers/update.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/numbers/update.js)_
372
-
373
- ## `fonoster plugins`
374
-
375
- List installed plugins.
376
-
377
- ```
378
- USAGE
379
- $ fonoster plugins
380
-
381
- OPTIONS
382
- --core Show core plugins.
383
-
384
- EXAMPLE
385
- $ fonoster plugins
386
- ```
387
-
388
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.1.0/src/commands/plugins/index.ts)_
389
-
390
- ## `fonoster plugins:inspect PLUGIN...`
391
-
392
- Displays installation properties of a plugin.
393
-
394
- ```
395
- USAGE
396
- $ fonoster plugins:inspect PLUGIN...
397
-
398
- ARGUMENTS
399
- PLUGIN [default: .] Plugin to inspect.
400
-
401
- OPTIONS
402
- -h, --help Show CLI help.
403
- -v, --verbose
404
-
405
- EXAMPLE
406
- $ fonoster plugins:inspect myplugin
407
- ```
408
-
409
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.1.0/src/commands/plugins/inspect.ts)_
410
-
411
- ## `fonoster plugins:install PLUGIN...`
412
-
413
- Installs a plugin into the CLI.
414
-
415
- ```
416
- USAGE
417
- $ fonoster plugins:install PLUGIN...
418
-
419
- ARGUMENTS
420
- PLUGIN Plugin to install.
21
+ ## Example
421
22
 
422
- OPTIONS
423
- -f, --force Run yarn install with force flag.
424
- -h, --help Show CLI help.
425
- -v, --verbose
23
+ A Voice Application is a server that controls a call's flow. A Voice Application can use any combination of the following verbs:
426
24
 
427
- DESCRIPTION
428
- Can be installed from npm or a git url.
25
+ - `Answer` - Accepts an incoming call
26
+ - `Dial` - Passes the call to an Agent or a Number at the PSTN
27
+ - `Hangup` - Closes the call
28
+ - `Play` - Takes a URL or file and streams the sound back to the calling party
29
+ - `Say` - Takes a text, synthesizes the text into audio, and streams back the result
30
+ - `Gather` - Waits for DTMF or speech events and returns back the result
31
+ - `SGather` - Returns a stream for future DTMF and speech results
32
+ - `Stream` - Starts a stream to read and write audio into the call
33
+ - `Record` - It records the voice of the calling party and saves the audio on the Storage sub-system
34
+ - `Mute` - It tells the channel to stop sending media, effectively muting the channel
35
+ - `Unmute` - It tells the channel to allow media flow
429
36
 
430
- Installation of a user-installed plugin will override a core plugin.
37
+ Voice Application Example:
431
38
 
432
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
433
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
434
- the CLI without the need to patch and update the whole CLI.
39
+ ```typescript
40
+ const VoiceServer = require("@fonoster/voice").default;
41
+ const {
42
+ GatherSource,
43
+ VoiceRequest,
44
+ VoiceResponse
45
+ } = require("@fonoster/voice");
435
46
 
436
- ALIASES
437
- $ fonoster plugins:add
47
+ new VoiceServer().listen(async (req: VoiceRequest, voice: VoiceResponse) => {
48
+ const { ingressNumber, sessionRef, appRef } = req;
438
49
 
439
- EXAMPLES
440
- $ fonoster plugins:install myplugin
441
- $ fonoster plugins:install https://github.com/someuser/someplugin
442
- $ fonoster plugins:install someuser/someplugin
443
- ```
50
+ await voice.answer();
444
51
 
445
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.1.0/src/commands/plugins/install.ts)_
52
+ await voice.say("Hi there! What's your name?");
446
53
 
447
- ## `fonoster plugins:link PLUGIN`
54
+ const { speech: name } = await res.gather({
55
+ source: GatherSource.SPEECH
56
+ });
448
57
 
449
- Links a plugin into the CLI for development.
58
+ await voice.say("Nice to meet you " + name + "!");
450
59
 
451
- ```
452
- USAGE
453
- $ fonoster plugins:link PLUGIN
60
+ await voice.say("Please enter your 4 digit pin.");
454
61
 
455
- ARGUMENTS
456
- PATH [default: .] path to plugin
62
+ const { digits } = await voice.gather({
63
+ maxDigits: 4,
64
+ finishOnKey: "#"
65
+ });
457
66
 
458
- OPTIONS
459
- -h, --help Show CLI help.
460
- -v, --verbose
67
+ await voice.say("Your pin is " + digits);
461
68
 
462
- DESCRIPTION
463
- Installation of a linked plugin will override a user-installed or core plugin.
69
+ await voice.hangup();
70
+ });
464
71
 
465
- e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
466
- command will override the user-installed or core plugin implementation. This is useful for development work.
467
-
468
- EXAMPLE
469
- $ fonoster plugins:link myplugin
72
+ // Your app will live at tcp://127.0.0.1:50061
73
+ // and you can easily publish it to the Internet with:
74
+ // ngrok tcp 50061
470
75
  ```
471
76
 
472
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.1.0/src/commands/plugins/link.ts)_
473
-
474
- ## `fonoster plugins:uninstall PLUGIN...`
77
+ <a name="VoiceResponse"></a>
475
78
 
476
- Removes a plugin from the CLI.
79
+ ## VoiceResponse <code>Verb</code>
80
+ Use the VoiceResponse object, to construct advance Interactive
81
+ Voice Response (IVR) applications.
477
82
 
478
- ```
479
- USAGE
480
- $ fonoster plugins:uninstall PLUGIN...
83
+ **Kind**: global class
84
+ **Extends**: <code>Verb</code>
85
+ **See**: module:core:APIClient
481
86
 
482
- ARGUMENTS
483
- PLUGIN plugin to uninstall
87
+ * [VoiceResponse](#VoiceResponse) ⇐ <code>Verb</code>
88
+ * [new VoiceResponse(request, voice)](#new_VoiceResponse_new)
89
+ * [.answer()](#VoiceResponse+answer)
90
+ * [.hangup()](#VoiceResponse+hangup)
91
+ * [.play(url, options)](#VoiceResponse+play)
92
+ * [.playDtmf(digits)](#VoiceResponse+playDtmf)
93
+ * [.playbackControl(playbackRef, action)](#VoiceResponse+playbackControl)
94
+ * [.gather(options)](#VoiceResponse+gather)
95
+ * [.say(text, options)](#VoiceResponse+say)
96
+ * [.record(options)](#VoiceResponse+record) ⇒ <code>RecordResponse</code>
97
+ * [.dial(destination, options)](#VoiceResponse+dial) ⇒ <code>Promise.&lt;DialStatusStream&gt;</code>
98
+ * [.stream(options)](#VoiceResponse+stream) ⇒ <code>Promise.&lt;Stream&gt;</code>
99
+ * [.sgather(options)](#VoiceResponse+sgather) ⇒ <code>Promise.&lt;StreamGatherStream&gt;</code>
100
+ * [.mute(options)](#VoiceResponse+mute)
101
+ * [.unmute(options)](#VoiceResponse+unmute)
102
+ * [.on(event, listener)](#VoiceResponse+on)
484
103
 
485
- OPTIONS
486
- -h, --help Show CLI help.
487
- -v, --verbose
104
+ <a name="new_VoiceResponse_new"></a>
488
105
 
489
- ALIASES
490
- $ fonoster plugins:unlink
491
- $ fonoster plugins:remove
492
- ```
106
+ ### new VoiceResponse(request, voice)
107
+ Constructs a new VoiceResponse object.
493
108
 
494
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.1.0/src/commands/plugins/uninstall.ts)_
495
109
 
496
- ## `fonoster plugins:update`
110
+ | Param | Type | Description |
111
+ | --- | --- | --- |
112
+ | request | <code>VoiceRequest</code> | Options to indicate the objects endpoint |
113
+ | voice | <code>VoiceSessionStream</code> | The voice session stream |
497
114
 
498
- Update installed plugins.
115
+ **Example**
116
+ ```js
117
+ import { VoiceServer } from "@fonoster/voice";
499
118
 
500
- ```
501
- USAGE
502
- $ fonoster plugins:update
119
+ async function handler (request, response) {
120
+ await response.answer();
121
+ await response.play("https://soundsserver:9000/sounds/hello-world.wav");
122
+ }
503
123
 
504
- OPTIONS
505
- -h, --help Show CLI help.
506
- -v, --verbose
124
+ new VoiceServer().listen(handler, { port: 3000 })
507
125
  ```
126
+ <a name="VoiceResponse+answer"></a>
508
127
 
509
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v2.1.0/src/commands/plugins/update.ts)_
510
-
511
- ## `fonoster projects:create`
512
-
513
- create a new Fonoster Project
128
+ ### voiceResponse.answer()
129
+ Answer the call. Before running any other verb you
130
+ must run the anwer command.
514
131
 
132
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
133
+ **Example**
134
+ ```js
135
+ async function handler (request, response) {
136
+ await response.answer();
137
+ }
515
138
  ```
516
- USAGE
517
- $ fonoster projects:create
518
-
519
- DESCRIPTION
520
- ...
521
- Create a new Fonoster Project
522
- ```
523
-
524
- _See code: [dist/commands/projects/create.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/projects/create.js)_
139
+ <a name="VoiceResponse+hangup"></a>
525
140
 
526
- ## `fonoster projects:delete [REF]`
141
+ ### voiceResponse.hangup()
142
+ Hangup the call.
527
143
 
528
- delete a Fonoster Project
529
-
530
- ```
531
- USAGE
532
- $ fonoster projects:delete [REF]
533
-
534
- ALIASES
535
- $ fonoster projects:del
536
- $ fonoster projects:rm
144
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
145
+ **Example**
146
+ ```js
147
+ async function handler (request, response) {
148
+ await response.hangup();
149
+ }
537
150
  ```
151
+ <a name="VoiceResponse+play"></a>
538
152
 
539
- _See code: [dist/commands/projects/delete.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/projects/delete.js)_
153
+ ### voiceResponse.play(url, options)
154
+ Play an audio in the call.
540
155
 
541
- ## `fonoster projects:get [REF]`
156
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
157
+ **See**: Playback
542
158
 
543
- get a Fonoster Project
159
+ | Param | Type | Description |
160
+ | --- | --- | --- |
161
+ | url | <code>string</code> | The URL of the media to play |
162
+ | options | <code>PlayOptions</code> | Options to control the playback |
163
+ | options.playbackRef | <code>string</code> | Playback identifier to use in Playback operations |
544
164
 
165
+ **Example**
166
+ ```js
167
+ async function handler (request, response) {
168
+ await response.answer();
169
+ await response.play("https://soundsserver:9000/sounds/hello-world.wav");
170
+ }
545
171
  ```
546
- USAGE
547
- $ fonoster projects:get [REF]
548
- ```
172
+ <a name="VoiceResponse+playDtmf"></a>
173
+
174
+ ### voiceResponse.playDtmf(digits)
175
+ Play a series of DTMF digits in a call.
176
+
177
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
178
+
179
+ | Param | Type | Description |
180
+ | --- | --- | --- |
181
+ | digits | <code>string</code> | The DTMF digits to play (0-9, #, or *) |
182
+
183
+ **Example**
184
+ ```js
185
+ async function handler (request, response) {
186
+ await response.answer();
187
+ await response.playDtmf("1234");
188
+ }
189
+ ```
190
+ <a name="VoiceResponse+playbackControl"></a>
191
+
192
+ ### voiceResponse.playbackControl(playbackRef, action)
193
+ Control the playback of the currently playing media.
194
+
195
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
196
+ **See**: play
197
+
198
+ | Param | Type | Description |
199
+ | --- | --- | --- |
200
+ | playbackRef | <code>string</code> | The playback identifier |
201
+ | action | <code>PlaybackControlAction</code> | The action to perform (STOP, RESTART, PAUSE, UNPAUSE, FORWARD) |
549
202
 
550
- _See code: [dist/commands/projects/get.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/projects/get.js)_
551
-
552
- ## `fonoster projects:list`
553
-
554
- list all Fonoster Projects you have access to
203
+ **Example**
204
+ ```js
205
+ async function handler (request, response) {
206
+ await response.answer();
207
+ await response.play("https://s3.fonoster.io/uuid/hello-world.wav", { playbackRef: "playback-01" });
555
208
 
209
+ // Pause the media
210
+ await response.playbackControl("playback-01", PlaybackControlAction.PAUSE);
211
+ }
212
+ ```
213
+ <a name="VoiceResponse+gather"></a>
214
+
215
+ ### voiceResponse.gather(options)
216
+ Waits for data entry from the user's keypad or from a speech provider.
217
+
218
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
219
+ **Note**: When including `SPEECH` the default timeout is 10000 (10s).
220
+
221
+ | Param | Type | Description |
222
+ | --- | --- | --- |
223
+ | options | <code>GatherOptions</code> | Options to select the maximum number of digits, final character, and timeout |
224
+ | options.maxDigits | <code>number</code> | Maximum number of digits to collect. Defaults to 1 |
225
+ | options.timeout | <code>number</code> | Milliseconds to wait before timeout. Defaults to 4000. Use zero for no timeout. |
226
+ | options.finishOnKey | <code>string</code> | Optional last character to wait for. Defaults to '#'. It will not be included in the returned digits |
227
+ | options.source | <code>GatherSource</code> | Where to listen as input source. This option accepts `DTMF` and `SPEECH`. A speech provider must be configure when including the `SPEECH` source. You might inclue both with `SPEECH_AND_DTMF`. Defaults to `SPEECH_AND_DTMF` |
228
+
229
+ **Example**
230
+ ```js
231
+ async function handler (request, response) {
232
+ await response.answer();
233
+ const speech = await response.gather({ source: GatherSource.SPEECH, numDigits: 3 });
234
+ console.log("speech: " + speech);
235
+ await response.hangup();
236
+ }
556
237
  ```
557
- USAGE
558
- $ fonoster projects:list
238
+ <a name="VoiceResponse+say"></a>
239
+
240
+ ### voiceResponse.say(text, options)
241
+ Send a text for a TTS engine to convert to speech.
242
+
243
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
244
+ **See**: Say
245
+
246
+ | Param | Type | Description |
247
+ | --- | --- | --- |
248
+ | text | <code>string</code> | The text to convert to speech |
249
+ | options | <code>SayOptions</code> | Options to control the TTS engine |
250
+ | options.playbackRef | <code>string</code> | Playback identifier to use in Playback operations |
251
+ | options.ttsOptions | <code>TTSOptions</code> | Options to control the TTS engine (specific to the TTS engine) |
252
+
253
+ **Example**
254
+ ```js
255
+ async function handler (request, response) {
256
+ await response.answer();
257
+ const playbackRef = await response.say("Hello World");
258
+
259
+ // Like the play verb, you can control the playback
260
+ await response.playbackControl(playbackRef, PlaybackControlAction.STOP);
261
+ }
262
+ ```
263
+ <a name="VoiceResponse+record"></a>
264
+
265
+ ### voiceResponse.record(options) ⇒ <code>RecordResponse</code>
266
+ Record the audio of the call.
267
+
268
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
269
+ **Returns**: <code>RecordResponse</code> - The record response
270
+
271
+ | Param | Type | Description |
272
+ | --- | --- | --- |
273
+ | options | <code>RecordOptions</code> | Options to control the record operation |
274
+ | options.maxDuration | <code>number</code> | The maximum duration of the recording in seconds. Default is 60 |
275
+ | options.maxSilence | <code>number</code> | The maximum duration of silence in seconds. Default is 5 |
276
+ | options.beep | <code>boolean</code> | Play a beep before recording. Default is true |
277
+ | options.finishOnKey | <code>string</code> | Stop recording when a DTMF digit is received. Default is '#' |
278
+
279
+ **Example**
280
+ ```js
281
+ async function handler (request, response) {
282
+ await response.answer();
283
+ const record = await response.record();
284
+ console.log("Recording: %s", record.name);
285
+ }
286
+ ```
287
+ <a name="VoiceResponse+dial"></a>
288
+
289
+ ### voiceResponse.dial(destination, options) ⇒ <code>Promise.&lt;DialStatusStream&gt;</code>
290
+ Dials a destination and returns a stream of status.
291
+
292
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
293
+ **Returns**: <code>Promise.&lt;DialStatusStream&gt;</code> - The dial status stream
294
+
295
+ | Param | Type | Description |
296
+ | --- | --- | --- |
297
+ | destination | <code>string</code> | The destination to dial |
298
+ | options | <code>DialOptions</code> | Options to control the dial operation |
299
+ | options.timeout | <code>number</code> | The timeout in seconds. Default is 60 |
300
+ | options.recordDirection | <code>RecordDirection</code> | The direction to record the call (IN, OUT, BOTH). Default is BOTH |
301
+
302
+ <a name="VoiceResponse+stream"></a>
303
+
304
+ ### voiceResponse.stream(options) ⇒ <code>Promise.&lt;Stream&gt;</code>
305
+ Starts a bidirectional audio stream between the call and the application.
306
+
307
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
308
+ **Returns**: <code>Promise.&lt;Stream&gt;</code> - The stream object
309
+
310
+ | Param | Type | Description |
311
+ | --- | --- | --- |
312
+ | options | <code>StreamOptions</code> | Options to control the stream operation |
313
+ | options.direction | <code>StreamDirection</code> | The direction to stream the audio (IN, OUT, BOTH). Default is BOTH |
314
+ | options.format | <code>StreamAudioFormat</code> | The audio format to stream (WAV). Default is WAV |
315
+
316
+ **Example**
317
+ ```js
318
+ async function handler (request, response) {
319
+ await response.answer();
320
+
321
+ const stream = await response.stream({
322
+ direction: StreamDirection.BOTH
323
+ });
324
+
325
+ stream.onPayload((payload) => {
326
+ // Use the payload
327
+ });
328
+
329
+ // Or write to the stream
330
+ // stream.write({ type: StreamMessageType.AUDIO_OUT, payload: "\x00\x01\x02" });
331
+ }
332
+ ```
333
+ <a name="VoiceResponse+sgather"></a>
559
334
 
560
- DESCRIPTION
561
- ...
562
- List all Fonoster Projects you have access to
335
+ ### voiceResponse.sgather(options) ⇒ <code>Promise.&lt;StreamGatherStream&gt;</code>
336
+ Starts a server-side stream gather operation which sends transcription data to the voice server.
563
337
 
564
- ALIASES
565
- $ fonoster projects:ls
566
- ```
567
-
568
- _See code: [dist/commands/projects/list.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/projects/list.js)_
569
-
570
- ## `fonoster projects:renew [REF]`
571
-
572
- renew the credentials of a Fonoster Project
338
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
339
+ **Returns**: <code>Promise.&lt;StreamGatherStream&gt;</code> - The stream gather object
340
+ **See**: Gather
573
341
 
342
+ | Param | Type | Description |
343
+ | --- | --- | --- |
344
+ | options | <code>StreamGatherOptions</code> | Options to control the stream gather operation |
345
+ | options.source | <code>StreamGatherSource</code> | The source to gather data from (DTMF, SPEECH, SPEECH_AND_DTMF). Default is SPEECH |
346
+
347
+ **Example**
348
+ ```js
349
+ async function handler (request, response) {
350
+ await response.answer();
351
+ const sGather = await response.streamGather({ source: StreamGatherSource.SPEECH });
352
+ sGather.onPayload((payload) => {
353
+ console.log("Payload: %s", payload);
354
+ });
355
+ }
574
356
  ```
575
- USAGE
576
- $ fonoster projects:renew [REF]
357
+ <a name="VoiceResponse+mute"></a>
577
358
 
578
- DESCRIPTION
579
- ...
580
- Renew the credentials of a Fonoster Project
581
- ```
582
-
583
- _See code: [dist/commands/projects/renew.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/projects/renew.js)_
359
+ ### voiceResponse.mute(options)
360
+ Mutes a call.
584
361
 
585
- ## `fonoster projects:use [REF]`
362
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
363
+ **See**: unmute
586
364
 
587
- set a default Fonoster Project
365
+ | Param | Type | Description |
366
+ | --- | --- | --- |
367
+ | options | <code>MuteOptions</code> | Options to control the mute operation |
368
+ | options.direction | <code>MuteDirection</code> | The direction to mute the channel (IN, OUT, BOTH). Default is BOTH |
588
369
 
370
+ **Example**
371
+ ```js
372
+ async function handler (request, response) {
373
+ await response.answer();
374
+ await response.mute(); // Will mute both directions
375
+ }
589
376
  ```
590
- USAGE
591
- $ fonoster projects:use [REF]
377
+ <a name="VoiceResponse+unmute"></a>
592
378
 
593
- DESCRIPTION
594
- ...
595
- Set a default Fonoster Project
596
- ```
379
+ ### voiceResponse.unmute(options)
380
+ Unmutes a call.
597
381
 
598
- _See code: [dist/commands/projects/use.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/projects/use.js)_
382
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
383
+ **See**: mute
599
384
 
600
- ## `fonoster providers:create`
601
-
602
- create a new Fonoster Provider (trunk)
603
-
604
- ```
605
- USAGE
606
- $ fonoster providers:create
607
-
608
- DESCRIPTION
609
- ...
610
- Create a new Fonoster Provider
611
- ```
612
-
613
- _See code: [dist/commands/providers/create.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/providers/create.js)_
614
-
615
- ## `fonoster providers:delete [REF]`
616
-
617
- delete a Fonoster Provider
618
-
619
- ```
620
- USAGE
621
- $ fonoster providers:delete [REF]
622
-
623
- ALIASES
624
- $ fonoster providers:del
625
- $ fonoster providers:rm
626
- ```
627
-
628
- _See code: [dist/commands/providers/delete.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/providers/delete.js)_
629
-
630
- ## `fonoster providers:get [REF]`
631
-
632
- get a Fonoster Provider
385
+ | Param | Type | Description |
386
+ | --- | --- | --- |
387
+ | options | <code>MuteOptions</code> | Options to control the unmute operation |
388
+ | options.direction | <code>MuteDirection</code> | The direction to unmute the call (IN, OUT, BOTH). Default is BOTH |
633
389
 
390
+ **Example**
391
+ ```js
392
+ async function handler (request, response) {
393
+ await response.answer();
394
+ await response.unmute(); // Will unmute both directions
395
+ }
634
396
  ```
635
- USAGE
636
- $ fonoster providers:get [REF]
637
- ```
638
-
639
- _See code: [dist/commands/providers/get.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/providers/get.js)_
397
+ <a name="VoiceResponse+on"></a>
640
398
 
641
- ## `fonoster providers:list`
642
-
643
- list all Fonoster Providers you have access to
644
-
645
- ```
646
- USAGE
647
- $ fonoster providers:list
399
+ ### voiceResponse.on(event, listener)
400
+ Register a listener for the given event.
648
401
 
649
- OPTIONS
650
- -s, --size=size [default: 25] provider of result per page
402
+ **Kind**: instance method of [<code>VoiceResponse</code>](#VoiceResponse)
651
403
 
652
- DESCRIPTION
653
- ...
654
- List all Fonoster Providers you have access to
404
+ | Param | Type | Description |
405
+ | --- | --- | --- |
406
+ | event | <code>StreamEvent</code> | The event to listen for |
407
+ | listener | <code>function</code> | The callback function |
655
408
 
656
- ALIASES
657
- $ fonoster providers:ls
658
- ```
659
-
660
- _See code: [dist/commands/providers/list.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/providers/list.js)_
661
-
662
- ## `fonoster providers:update [REF]`
663
-
664
- update a Fonoster Provider
665
-
666
- ```
667
- USAGE
668
- $ fonoster providers:update [REF]
409
+ **Example**
410
+ ```js
411
+ async function handler (request, response) {
412
+ ...
669
413
 
670
- DESCRIPTION
671
- ...
672
- Update a Fonoster Provider
414
+ response.on(StreamEvent.END, () => {
415
+ console.log("Call ended");
416
+ });
417
+ }
673
418
  ```
674
419
 
675
- _See code: [dist/commands/providers/update.js](https://github.com/fonoster/fonoster/blob/v0.4.0/dist/commands/providers/update.js)_
676
- <!-- commandsstop -->