What each context sees
Every context is a fresh run of your compiled bundle with the platform objects injected as globals:User, Data, Products, Baskets, Orders, Jobs, Workflows, AI, Agents, Integrations, Voice, Channels, Team, Templates, CDN, Lua, and env, plus fetch, console, and process.env. The imports from 'lua-cli' exist for types and for lua test; at run time they resolve to the injected objects.
In a conversation context (tools, conditions, processors, the model resolver)
User.get() returns the end user who sent the message, and Lua.request.channel is where they sent it from, so a tool can branch on channel or read the end user’s stored profile.
src/skills/tools/GetGreetingTool.ts
User.get(userId) with an ID you stored earlier, or User.get({ email }) / User.get({ phone }), which return null when nobody matches. A bare User.get() there fails as a platform error, User.Inbox.push refuses with Inbox.push requires a user context, and job.user() on a job that wasn’t created from a user’s tool throws User API not initialized. Lua.request.channel in those contexts is the string unknown.
No context exposes a thread ID to your code. User.getChatHistory() returns the end user’s history with the agent as a whole, and Agents.invoke returns the thread it used.
Runtime constraints
Each invocation runs in a fresh, isolated VM context that is discarded afterwards, so nothing at module scope survives: no in-memory caches, counters, or connection pools between calls. Persist state withData or on the User record.
Jobs.create sends the job’s execute function to the server as source text. Variables it closes over are not sent with it; pass what the job needs in metadata and read job.metadata inside.
A webhook’s secret must be a string literal or a constant the compiler can read; lua compile fails on a runtime expression rather than deploy an unsigned webhook.
console.log, console.info, console.warn, and console.error are captured into lua logs; other console methods are not provided. Output isn’t scrubbed for secrets, so don’t log credentials. A tool result larger than 300,000 characters reaches the model as a truncated preview.
Your code can call any public host with fetch. Private-network and cloud-metadata addresses are not a supported destination, and Node modules such as child_process, worker_threads, and vm are not supported in the sandbox.
A context and a channel
A channel is where the end user is; a context is where your code is. The same tool runs in the same context whether the message came from WhatsApp or the web widget, and readsLua.request.channel to tell them apart. A webhook, by contrast, has no channel because no end user started it, so the value is unknown however the message it eventually sends goes out.
When it matters
- Sending a message from a webhook or job: look the end user up by ID first, then
user.send(…)orChannels.send(…). - Behavior that differs by channel: read
Lua.request.channelin a tool, a processor, or the model resolver, not in a webhook. - Work that needs more than a tool’s budget: return quickly and hand off to
Jobs.createorWorkflows.start. - A tool that must be hidden for some end users: a
condition, which runs in the conversation context and can read the end user.
Limits
- Time budgets are in the table; a job’s
timeoutmust be an integer from 1 to 600 seconds. A tool that hits its budget is not retried; the call fails. A job attempt that hits itstimeoutcounts as failed and is retried when the job hasretry. - A job is refused before
executeruns when loading its bundle and preparing its context took more than 128 MB of heap:Memory limit exceeded before execution. Nothingexecuteallocates counts, so the lever on your side is bundle size: trim top-level imports. The check applies to jobs only, and the refused attempt is retried like any failed one. - Tool results are capped at 300,000 characters; captured log lines at 256 KB per field.
- Trigger slots share a single 15-second budget, so keep signature checks and filtering cheap.
Next steps
SDK reference
Every platform object and where it is available.
User reference
get, lookups by email or phone, send, and Inbox.Identify users
Carry a user ID from a conversation into a webhook or job.
Logs and debugging
Read what each context logged.

