mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-19 04:17:44 +00:00
add support for sending DTMF to ultravox (#1471)
This commit is contained in:
@@ -146,8 +146,9 @@ class TaskLlmUltravox_S2S extends Task {
|
||||
return data;
|
||||
}
|
||||
|
||||
_unregisterHandlers() {
|
||||
_unregisterHandlers(ep) {
|
||||
this.removeCustomEventListeners();
|
||||
ep.removeAllListeners('dtmf');
|
||||
}
|
||||
|
||||
_registerHandlers(ep) {
|
||||
@@ -155,6 +156,7 @@ class TaskLlmUltravox_S2S extends Task {
|
||||
this.addCustomEventListener(ep, LlmEvents_Ultravox.ConnectFailure, this._onConnectFailure.bind(this, ep));
|
||||
this.addCustomEventListener(ep, LlmEvents_Ultravox.Disconnect, this._onDisconnect.bind(this, ep));
|
||||
this.addCustomEventListener(ep, LlmEvents_Ultravox.ServerEvent, this._onServerEvent.bind(this, ep));
|
||||
ep.on('dtmf', this._onDtmf.bind(this, ep));
|
||||
}
|
||||
|
||||
async _startListening(cs, ep) {
|
||||
@@ -189,7 +191,7 @@ class TaskLlmUltravox_S2S extends Task {
|
||||
/* note: the parent llm verb started the span, which is why this is necessary */
|
||||
await this.parent.performAction(this.results);
|
||||
|
||||
this._unregisterHandlers();
|
||||
this._unregisterHandlers(ep);
|
||||
}
|
||||
|
||||
async kill(cs) {
|
||||
@@ -346,6 +348,18 @@ class TaskLlmUltravox_S2S extends Task {
|
||||
excludeEvents: this.excludeEvents
|
||||
}, 'TaskLlmUltravox_S2S:_populateEvents');
|
||||
}
|
||||
|
||||
_onDtmf(ep, evt) {
|
||||
this.logger.info({evt}, 'TaskLlmUltravox_S2S:_onDtmf - DTMF received');
|
||||
const {dtmf} = evt;
|
||||
const data = {
|
||||
type: 'user_text_message',
|
||||
text: `DTMF received: ${dtmf}`,
|
||||
urgency: 'immediate'
|
||||
};
|
||||
this._api(ep, [ep.uuid, ClientEvent, JSON.stringify(data)])
|
||||
.catch((err) => this.logger.info({err, evt}, 'TaskLlmUltravox_S2S:_onDtmf - Error sending DTMF as text message'));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TaskLlmUltravox_S2S;
|
||||
|
||||
Reference in New Issue
Block a user