Skip to main content
Lua.request tells your code which channel the current turn came from and, on channels that deliver messages by webhook, the raw payload the provider sent. It is defined in every execution context. Outside a conversation turn, in a job, a webhook, or a trigger, there is no inbound channel: channel is unknown and webhook is undefined. A model resolver on LuaAgent receives the same LuaRequest as its argument. Verified against lua-cli 3.33.0.

Quick example

A tool condition can hide the tool on channels where it makes no sense.

Properties

request.channel

The channel the current turn arrived on.
Channel is a union of the common names plus string, so comparing against any value type-checks. Keep a default branch. The outbound names on Channels.send differ for two channels: webchat sends to the web widget, and messenger sends to facebook.

request.webhook

The provider’s raw event for the inbound message, when the channel delivers by webhook.
webhook is set when the provider delivered the message by webhook, which is the case for WhatsApp, Messenger, Instagram, Slack, and email, and undefined for the web widget, the REST API, lua test, and every context outside a turn. payload is the provider’s own object: the WhatsApp Cloud API webhook entry, the Slack Events API event, and so on. For email it is a parsed message rather than raw MIME: messageId, inReplyTo, references, subject, from, to, cc, bcc, replyTo, date, and headerLines, where the ids are bare (no angle brackets) and each address is { address, name }. Example

Types

interface
{ request: LuaRequest }, the type of Lua.
interface
{ channel: Channel; webhook?: WebhookRequest }. Also the argument type of a model resolver, LuaAgentModel = string | ((request: LuaRequest) => string | Promise<string>).
interface
{ payload: any }.
union
'web' | 'whatsapp' | 'facebook' | 'instagram' | 'slack' | 'teams' | 'front' | 'messagebird' | 'api' | 'dev' | 'email' | string. The runtime also produces the values listed under request.channel that the union doesn’t spell out.

See also