@voctiv/agent-sdk 0.2.4 → 0.2.5

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 (2) hide show
  1. package/README.md +22 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -103,6 +103,28 @@ The important states are:
103
103
  - `active`: final 200 OK has been received or sent.
104
104
  - `terminated`: the call ended and no more audio is possible.
105
105
 
106
+ ### How Pre-Answer Works
107
+
108
+ Pre-answer means the SIP media path is open before the call is finally answered with `200 OK`. In this state the caller can already hear TTS, the script can already receive audio for ASR, and DTMF can be exchanged.
109
+
110
+ Use pre-answer when you need to do something before committing the call to the final answer state:
111
+
112
+ - play an informational greeting or disclaimer;
113
+ - collect a short value with ASR, such as account number or menu choice;
114
+ - detect and navigate an IVR that speaks before answering;
115
+ - delay `answer()` until the script is ready to transfer, bridge, or continue.
116
+
117
+ For inbound calls, the script controls this explicitly:
118
+
119
+ 1. Call `channel.sip.sendProgress()` to send `183 Session Progress` with SDP.
120
+ 2. Wait for `channel.sip.waitForEarly()` if your next logic step needs media to be ready.
121
+ 3. Use `channel.audio.say()`, `channel.audio.play()`, `channel.createAsr()`, or `channel.sip.sendDtmf()` normally.
122
+ 4. Call `channel.sip.answer()` when you want to send the final `200 OK`.
123
+
124
+ For outbound calls, pre-answer is controlled by the remote side. If the remote endpoint sends `183 Session Progress` with SDP, ScriptEngine moves the call to `early`. If it answers directly, `waitForEarly()` resolves when the call becomes `active`.
125
+
126
+ `early` is a media-ready state, not a final answer state. `answer()` is still the explicit transition that sends final `200 OK` for inbound calls. External billing behavior depends on the carrier.
127
+
106
128
  ### Outbound Pre-Answer
107
129
 
108
130
  For outbound calls, early media starts when the remote side sends a provisional response with SDP, usually `183 Session Progress`. This is useful for IVRs that speak before answering.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voctiv/agent-sdk",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Voctiv TypeScript agent SDK: defineScript and platform types for the voice/dialog scripting runtime.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",