what are the data fields that can be passed in job...
# ask-ai
c
what are the data fields that can be passed in job.metadata?
t
Thanks for reaching out, Subham. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm happy to help you understand the
job.metadata
field in LiveKit! This field is a flexible, freeform string where you can include any data you'd like to pass along to an agent job. To keep things organized, LiveKit suggests using JSON or similar structured formats, especially if you want to share complex or multiple pieces of information. For instance, you might want to include details like
user_id
,
user_name
, and
user_phone
within a JSON string. This way, the agent can easily parse and use these values, like in the example below:
Copy code
import json

async def entrypoint(ctx: JobContext):
    metadata = json.loads(ctx.job.metadata)
    user_id = metadata["user_id"]
    user_name = metadata["user_name"]
    user_phone = metadata["user_phone"]
When you dispatch a job through the API or CLI, you set the actual content of
job.metadata
. Feel free to include any key-value pairs you need, encoded as a string. There aren’t any strict restrictions on the fields—just keep in mind the practical limits like string size and JSON parsing. If you have any more questions or want to explore this further, I'm here to help! Sources: Job lifecycle | LiveKit Docs | Agent dispatch | LiveKit Docs | cmd/lk/token.go