@@ -43,7 +43,7 @@ export const questionEvent = defineUpdate<Question>("question");
4343
4444export const answerEvent = defineUpdate < Answer > ( "answer" ) ;
4545
46- const streamEnd = defineUpdate ( "streamEnd" ) ;
46+ export const streamEnd = defineUpdate ( "streamEnd" ) ;
4747
4848export async function twilioStreamWorkflow ( ) {
4949 let currentstreamSid : string ;
@@ -76,9 +76,18 @@ export async function twilioStreamWorkflow() {
7676
7777 await step < typeof streams > ( {
7878 podName : `websocket` ,
79- scheduleToCloseTimeout : "2 minutes " ,
79+ scheduleToCloseTimeout : "1 minute " ,
8080 } ) . sendAudio ( { streamSid, trackName : "agent" , audio } ) ;
8181
82+ await step < typeof streams > ( {
83+ podName : `websocket` ,
84+ scheduleToCloseTimeout : "2 minutes" ,
85+ } ) . sendEvent ( {
86+ streamSid,
87+ eventName : answerEvent . name ,
88+ data : { text : welcomeMessage . partialResponse } ,
89+ } ) ;
90+
8291 currentstreamSid = streamSid ;
8392 return { streamSid } ;
8493 } ) ;
@@ -92,6 +101,15 @@ export async function twilioStreamWorkflow() {
92101
93102 interactionCount += 1 ;
94103
104+ await step < typeof streams > ( {
105+ podName : `websocket` ,
106+ scheduleToCloseTimeout : "1 minute" ,
107+ } ) . sendEvent ( {
108+ streamSid,
109+ eventName : questionEvent . name ,
110+ data : { text : finalResult } ,
111+ } ) ;
112+
95113 await step < typeof functions > ( {
96114 podName : `openai` ,
97115 scheduleToCloseTimeout : "2 minutes" ,
@@ -109,6 +127,15 @@ export async function twilioStreamWorkflow() {
109127 scheduleToCloseTimeout : "2 minutes" ,
110128 } ) . textToAudio ( { streamSid, trackName, gptReply, interactionCount } ) ;
111129
130+ await step < typeof streams > ( {
131+ podName : `websocket` ,
132+ scheduleToCloseTimeout : "1 minute" ,
133+ } ) . sendEvent ( {
134+ streamSid,
135+ eventName : answerEvent . name ,
136+ data : { text : gptReply . partialResponse } ,
137+ } ) ;
138+
112139 log . info ( "audio" , { audio : audio ?. length } ) ;
113140
114141 if ( audio ) {
0 commit comments