Add method field to Daily DTMF output frames
Lets callers specify Daily's DTMF delivery method (e.g. "rfc2833" or "info") alongside `session_id` and `digit_duration_ms`. Forwarded to Daily's `send_dtmf` as `method`.
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
- Added `DailyTransport.send_dtmf()` to expose the Daily call client's DTMF sending capability, enabling applications to send tones during a call (e.g. IVR navigation).
|
- Added `DailyTransport.send_dtmf()` to expose the Daily call client's DTMF sending capability, enabling applications to send tones during a call (e.g. IVR navigation).
|
||||||
- Added `buttons` field to `OutputDTMFFrame` and `OutputDTMFUrgentFrame` for sending multi-key DTMF sequences as a `list[KeypadEntry]`. Use `OutputDTMFFrame.from_string("123#")` (or the equivalent on `OutputDTMFUrgentFrame`) to build one from a dial string.
|
- Added `buttons` field to `OutputDTMFFrame` and `OutputDTMFUrgentFrame` for sending multi-key DTMF sequences as a `list[KeypadEntry]`. Use `OutputDTMFFrame.from_string("123#")` (or the equivalent on `OutputDTMFUrgentFrame`) to build one from a dial string.
|
||||||
- Added `DailyOutputDTMFFrame` and `DailyOutputDTMFUrgentFrame` frames. In addition to the inherited `buttons`, they accept `session_id` and `digit_duration_ms`, which are forwarded to Daily's `send_dtmf` as `sessionId` and `digitDurationMs`.
|
- Added `DailyOutputDTMFFrame` and `DailyOutputDTMFUrgentFrame` frames. In addition to the inherited `buttons`, they accept `session_id`, `digit_duration_ms` and `method`, which are forwarded to Daily's `send_dtmf` as `sessionId`, `digitDurationMs` and `method`.
|
||||||
|
|||||||
@@ -158,38 +158,45 @@ class DailyOutputDTMFFrame(OutputDTMFFrame):
|
|||||||
"""DTMF output frame with Daily-specific options for transport queuing.
|
"""DTMF output frame with Daily-specific options for transport queuing.
|
||||||
|
|
||||||
A DTMF keypress output that will be queued after any preceding audio has
|
A DTMF keypress output that will be queued after any preceding audio has
|
||||||
finished playing. Inherits ``tones`` from :class:`OutputDTMFFrame`; the
|
finished playing. Inherits ``buttons`` from :class:`OutputDTMFFrame`; the
|
||||||
two extra fields are forwarded to Daily's ``send_dtmf`` as ``sessionId``
|
extra fields are forwarded to Daily's ``send_dtmf`` as ``sessionId``,
|
||||||
and ``digitDurationMs``.
|
``digitDurationMs`` and ``method``.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
session_id: Target participant session id. When ``None``, Daily
|
session_id: Target participant session id. When ``None``, Daily
|
||||||
sends the tones to the default destination for the call.
|
sends the tones to the default destination for the call.
|
||||||
digit_duration_ms: Duration of each DTMF digit in milliseconds.
|
digit_duration_ms: Duration of each DTMF digit in milliseconds.
|
||||||
When ``None``, Daily's default duration is used.
|
When ``None``, Daily's default duration is used.
|
||||||
|
method: DTMF delivery method (e.g. ``"telephone-event"``, ``"sip-info"``
|
||||||
|
or ``auto``). When ``None``, Daily's default method is used.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
session_id: Optional[str] = None
|
session_id: Optional[str] = None
|
||||||
digit_duration_ms: Optional[int] = None
|
digit_duration_ms: Optional[int] = None
|
||||||
|
method: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class DailyOutputDTMFUrgentFrame(OutputDTMFUrgentFrame):
|
class DailyOutputDTMFUrgentFrame(OutputDTMFUrgentFrame):
|
||||||
"""DTMF output frame with Daily-specific options for immediate sending.
|
"""DTMF output frame with Daily-specific options for immediate sending.
|
||||||
|
|
||||||
A DTMF keypress output that will be sent right away. Inherits ``tones``
|
A DTMF keypress output that will be sent right away. Inherits
|
||||||
from :class:`OutputDTMFUrgentFrame`; the two extra fields are forwarded
|
``buttons`` from :class:`OutputDTMFUrgentFrame`; the extra fields are
|
||||||
to Daily's ``send_dtmf`` as ``sessionId`` and ``digitDurationMs``.
|
forwarded to Daily's ``send_dtmf`` as ``sessionId``, ``digitDurationMs``
|
||||||
|
and ``method``.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
session_id: Target participant session id. When ``None``, Daily
|
session_id: Target participant session id. When ``None``, Daily
|
||||||
sends the tones to the default destination for the call.
|
sends the tones to the default destination for the call.
|
||||||
digit_duration_ms: Duration of each DTMF digit in milliseconds.
|
digit_duration_ms: Duration of each DTMF digit in milliseconds.
|
||||||
When ``None``, Daily's default duration is used.
|
When ``None``, Daily's default duration is used.
|
||||||
|
method: DTMF delivery method (e.g. ``"telephone-event"``, ``"sip-info"``
|
||||||
|
or ``auto``). When ``None``, Daily's default method is used.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
session_id: Optional[str] = None
|
session_id: Optional[str] = None
|
||||||
digit_duration_ms: Optional[int] = None
|
digit_duration_ms: Optional[int] = None
|
||||||
|
method: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
class WebRTCVADAnalyzer(VADAnalyzer):
|
class WebRTCVADAnalyzer(VADAnalyzer):
|
||||||
@@ -2178,9 +2185,9 @@ class DailyOutputTransport(BaseOutputTransport):
|
|||||||
Args:
|
Args:
|
||||||
frame: The DTMF frame to write. When it is a
|
frame: The DTMF frame to write. When it is a
|
||||||
:class:`DailyOutputDTMFFrame` or
|
:class:`DailyOutputDTMFFrame` or
|
||||||
:class:`DailyOutputDTMFUrgentFrame`, the ``session_id`` and
|
:class:`DailyOutputDTMFUrgentFrame`, the ``session_id``,
|
||||||
``digit_duration_ms`` fields are also forwarded to the Daily
|
``digit_duration_ms`` and ``method`` fields are also
|
||||||
call client.
|
forwarded to the Daily call client.
|
||||||
"""
|
"""
|
||||||
if not frame.buttons:
|
if not frame.buttons:
|
||||||
return
|
return
|
||||||
@@ -2191,6 +2198,8 @@ class DailyOutputTransport(BaseOutputTransport):
|
|||||||
settings["sessionId"] = frame.session_id
|
settings["sessionId"] = frame.session_id
|
||||||
if frame.digit_duration_ms is not None:
|
if frame.digit_duration_ms is not None:
|
||||||
settings["digitDurationMs"] = frame.digit_duration_ms
|
settings["digitDurationMs"] = frame.digit_duration_ms
|
||||||
|
if frame.method is not None:
|
||||||
|
settings["method"] = frame.method
|
||||||
|
|
||||||
await self._client.send_dtmf(settings)
|
await self._client.send_dtmf(settings)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user