steep-balloon-41261
12/05/2025, 4:51 PMtall-airline-16756
12/05/2025, 4:51 PMtall-airline-16756
12/05/2025, 4:52 PMfrom livekit.agents.beta.workflows import GetEmailTask
email_result = await GetEmailTask(chat_ctx=self.chat_ctx)
print(f"Collected email: {email_result.email_address}")
• The task prompts the user, transcribes speech, parses the response, and validates the email.
• If the user declines or no valid email is collected, the task returns no result.
Customize behavior
• Add extra_instructions to change prompts or fallback logic.
• Provide tools (callable function tools) to handle alternatives (e.g., collect phone number) when email isn’t available.
Example with an alternative contact tool:
@function_tool()
async def get_alternate_contact_info(context: RunContext, contact_method: str, contact_value: str):
context.session.userdata.alternate_contact_method = contact_method
context.session.userdata.alternate_contact_value = contact_value
await context.session.generate_reply(
instructions=f"Got it, I’ll use {contact_method}: {contact_value} for communication."
)
email_result = await GetEmailTask(
chat_ctx=self.chat_ctx,
extra_instructions="If the user can't provide an email, ask for another contact using get_alternate_contact_info.",
tools=[get_alternate_contact_info]
)
Key options
• `chat_ctx`: current conversation context (required).
• `extra_instructions`: string to guide prompts.
• `tools`: list of tools the task can call during collection.
Notes
• GetEmailTask is in livekit.agents.beta.workflows and currently supports Python.
• Ensure speech-to-text (STT) is configured for voice conversations.
Would you like a tailored example for your agent structure or help adding validation/alternate-contact logic?
Sources: Tasks and task groups | LiveKit docs