@micdrop/telephony 0.0.0-stage → 0.2.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.
- package/README.md +72 -2
- package/dist/index.d.mts +1141 -0
- package/dist/index.d.ts +1141 -0
- package/dist/index.js +2423 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2364 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +52 -4
package/README.md
CHANGED
|
@@ -1,3 +1,73 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 🖐️🎤 Micdrop: Real-Time Voice Conversations with AI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Micdrop website](https://micdrop.dev) | [Documentation](https://micdrop.dev/docs/transports/telephony)
|
|
4
|
+
|
|
5
|
+
Micdrop is a set of open source Typescript packages to build real-time voice conversations with AI agents. It handles all the complexities on the client and server side (microphone, speaker, VAD, network communication, etc) and provides ready-to-use implementations for various AI providers.
|
|
6
|
+
|
|
7
|
+
# @micdrop/telephony
|
|
8
|
+
|
|
9
|
+
Phone calls with a Micdrop voice agent, on your own Node.js server. The transports of this package run a call on the media stream WebSocket of a telephony provider, with the same agent, speech to text and text to speech as in the browser.
|
|
10
|
+
|
|
11
|
+
| Provider | Transport | Audio | Document that connects the call |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| Twilio, SignalWire | `TwilioTransport` | μ-law, 8 kHz | `twilioStreamTwiml()` |
|
|
14
|
+
| Vonage | `VonageTransport` | Linear PCM, 16 kHz | `vonageConnectNcco()` |
|
|
15
|
+
| Telnyx | `TelnyxTransport` | μ-law or A-law, 8 kHz | `telnyxStreamOptions()` |
|
|
16
|
+
| Plivo | `PlivoTransport` | μ-law, 8 kHz | `plivoStreamXml()` |
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @micdrop/server @micdrop/telephony @micdrop/silero onnxruntime-node
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { MicdropServer, waitForParams } from '@micdrop/server'
|
|
26
|
+
import { TwilioTransport, twilioStreamTwiml } from '@micdrop/telephony'
|
|
27
|
+
import '@micdrop/silero/node'
|
|
28
|
+
|
|
29
|
+
// The voice webhook of the number
|
|
30
|
+
app.post('/twilio/voice', async (request, reply) => {
|
|
31
|
+
reply.type('text/xml')
|
|
32
|
+
return twilioStreamTwiml({ url: 'wss://example.com/twilio/stream' })
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
// The stream Twilio opens
|
|
36
|
+
app.get('/twilio/stream', { websocket: true }, async (socket) => {
|
|
37
|
+
const transport = new TwilioTransport(socket)
|
|
38
|
+
const params = await waitForParams(transport, (value) => value)
|
|
39
|
+
|
|
40
|
+
new MicdropServer(transport, {
|
|
41
|
+
turns: { vad: 'silero' }, // A phone line needs the server to find the turns
|
|
42
|
+
firstMessage: 'Hello, thanks for calling. How can I help?',
|
|
43
|
+
agent,
|
|
44
|
+
stt,
|
|
45
|
+
tts,
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## What every transport does
|
|
51
|
+
|
|
52
|
+
- Brings the caller to 16 kHz for the speech to text, and the assistant voice to the rate of the line, with a low pass filter
|
|
53
|
+
- Drops the audio the provider still holds when the caller speaks over the assistant
|
|
54
|
+
- Hangs up once the goodbye has played when the agent ends the call, confirmed by the marks of the provider
|
|
55
|
+
- Hands the parameters of the call to `waitForParams`, and the call identifiers to `transport.call`
|
|
56
|
+
- Emits the keys of the keypad as `Dtmf` events
|
|
57
|
+
- Ends the call with a clear error when the stream comes in another format than it reads
|
|
58
|
+
|
|
59
|
+
## Production features
|
|
60
|
+
|
|
61
|
+
Each one is optional, added when you need it:
|
|
62
|
+
|
|
63
|
+
- `transferCallTool()`: the agent transfers the call, cold or warm (the person hears a summary first)
|
|
64
|
+
- `sendDtmfTool()` and `transport.sendDtmf()`: press keys in a phone menu
|
|
65
|
+
- `twilioCall()`, `vonageCall()`, `telnyxCall()`, `plivoCall()`: place outbound calls
|
|
66
|
+
- `answeringMachine()`, `voicemailTool()`: detect a voicemail, leave a message and hang up
|
|
67
|
+
- `validateTwilioSignature()`, `validateTelnyxSignature()`, `validateVonageSignature()`, `validatePlivoSignature()`: refuse the webhooks your provider did not sign
|
|
68
|
+
- `TelephonyCalls`: routes the webhooks of the providers (machine detection, Telnyx transfers) to their calls
|
|
69
|
+
- From `@micdrop/server`: `dtmfInput()` adds the keys of the caller to the conversation, `idleTimeout()` checks in when the caller stays silent
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
MIT
|