refined-hydrogen-81988
11/27/2025, 8:39 PMon_user_turn_completed in my agent definition, but it is not being called after text chat messages, how to do that?tall-airline-16756
11/27/2025, 8:39 PMtall-airline-16756
11/27/2025, 8:40 PMon_user_turn_completed hook: it only fires after audio input ends (VAD/STT/turn-detection). Text messages sent via chat do not trigger that hook.
To handle text chat messages, use the text input callback (text_input_cb / textInputCallback) in your RoomInputOptions / inputOptions. Example patterns:
Python:
def custom_text_input_handler(session: AgentSession, event: TextInputEvent) -> None:
message = event.text
session.interrupt()
session.generate_reply(user_input=message)
session = AgentSession(
# ...
room_input_options=RoomInputOptions(
text_input_cb=custom_text_input_handler
)
)
Node.js:
const customTextInputHandler = (session: voice.AgentSession, event: voice.TextInputEvent): void => {
const message = event.text;
session.interrupt();
session.generateReply({ userInput: message });
};
await session.start({
// ...
inputOptions: {
textInputCallback: customTextInputHandler,
},
});
Would you like help converting your current handler to use text_input_cb, or to share the relevant code so I can suggest the exact changes?
Sources: Pipeline nodes and hooks | LiveKit docs | Turn detection and interruptions | LiveKit Docs | Text and transcriptions | LiveKit docs