refined-hydrogen-81988
10/23/2025, 8:33 PMtall-airline-16756
10/23/2025, 8:34 PMtall-airline-16756
10/23/2025, 8:34 PMrefined-hydrogen-81988
10/23/2025, 8:35 PMtall-airline-16756
10/23/2025, 8:35 PMconst userData = { name: "Alice", age: 30, city: "Madrid" };
You can send this data to your backend using an API call or WebSocket.
2. Send Data to Backend:
Try using a POST request to send the data:
fetch('/start-agent', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(userData)
});
3. Backend Receives and Passes Metadata:
On the backend, you’ll want to include the received data as metadata when starting the agent job:
async def start_agent_job(request):
user_data = await request.json()
metadata = {
"name": user_data["name"],
"age": user_data["age"],
"city": user_data["city"]
}
await livekit.start_agent_job(metadata=metadata)
4. Access Metadata in the Agent:
Then, in the agent’s entrypoint, you can easily retrieve the metadata:
async def entrypoint(ctx: JobContext):
user_name = ctx.metadata.get("name")
user_age = ctx.metadata.get("age")
user_city = ctx.metadata.get("city")
print(f"User: {user_name}, Age: {user_age}, City: {user_city}")
This method helps make sure your front-end data smoothly reaches the backend and is included as metadata for the agent session. If anything’s unclear or you want to dive deeper, just let me know—I’m here to help!refined-hydrogen-81988
10/23/2025, 8:39 PMtall-airline-16756
10/23/2025, 8:40 PM