Overview
Use GetAddressTask to collect and validate a complete mailing address from the user. The task supports international addresses and automatically normalizes spoken address formats.
GetAddressTask handles the following:
- Accepts addresses from any country and normalizes different address formats.
- Converts words like "dash" and "apostrophe" into symbols (
-,'), and spelled-out numbers into numerals. - Processes postal codes digit-by-digit.
- Prompts for address components in order: street address, unit number (if applicable), locality, and country.
The task returns a GetAddressResult data class with one field: address.
Usage
The following example uses GetAddressTask to collect a user's mailing address:
from livekit.agents.beta.workflows import GetAddressTaskfrom livekit.agents import Agent, function_tool, RunContext@function_tool()async def collect_shipping_address(context: RunContext) -> str:"""Collect the user's shipping address"""address_result = await GetAddressTask(chat_ctx=context.session.chat_ctx,extra_instructions="Emphasize that this is for shipping purposes and accuracy is important.")return f"Shipping address recorded: {address_result.address}"
Parameters
For a full list of parameters, see the GetAddressTask reference.
stringOptionalAdditional instructions to append to the task's default instructions.
ChatContextOptionalThe conversation history the task-specific LLM sees. If you omit it, the task runs with an empty context, with no memory of what was said earlier in the session. Pass the primary agent's chat context so the task can refer to prior turns and, when used inside a task group, so exchanges are summarized back into the main context.
boolOptionalWhether to read the address back to the user to confirm it before finalizing the task. For audio sessions this defaults to True, for text it defaults to False.
listOptionalAdditional tools available to the task. Use this to add or substitute function tools.