Sign Up
Loading...

Realtime commands

Use these commands in endpoints, server functions and events to connect authenticated customers and send live notifications. Start with Realtime channels to create a channel and choose its audience.

Authorize Realtime

Issue a one-use connection ticket for the signed-in customer. Call it from a customer-authenticated endpoint, or from a function called by that endpoint. A scheduled event and the editor's Test runner have no customer login and cannot issue a customer's ticket.

Choose channel and set Return as. The result contains ticket, expiresAt, channel and mode. Return it to that customer's app. The ticket expires after 60 seconds and must be sent in the first connection message. Get a new ticket for every new connection; keep it out of connection addresses, logs and shared data.

The Private to each user audience follows the authenticated customer's identity. Clients cannot select a different customer's identity.

Publish Realtime Message

Send a notification using channel, event and data. For a private channel, also provide recipient_id, the destination customer's ID. A shared channel does not accept a private recipient.

For example, after saving an order's new status, publish event order_ready with data containing the order ID and status. Send it to the order owner's customer ID when using a private channel.

The result is true after submission. It is not a delivery receipt. Disconnected apps do not receive past messages, so save important changes in the database and reload them when reconnecting.

Testing and limits

For a full connection check, sign in with a synthetic customer in your Dev workspace and call its authenticated API endpoint. The editor's Test runner cannot issue tickets. Publish commands from editor tests use a separate audience and cannot reach customers connected to real API calls. Messages must fit within 64 KiB including event details. A workspace allows up to 120 publish attempts per minute and a customer up to 20 ticket requests per minute.

These commands run in server workflows. They do not let an app publish directly through its receiving connection. Channel settings and the customer's current permissions are checked before access is granted.

Related Topics

Miscellaneous

Twidget provides several miscellaneous commands to facilitate various tasks. Is Null. Description: Checks whether the provided value is null or not. Inputs: - value: The value to be checked. Output: - boolean: Returns `true` if the value is null; otherwise, returns `false`. Not Null. Description: Ch...

Conversion

Overview. Twidget's conversion commands allow you to easily convert different data types to the required format. Below is a list of the available conversion commands and examples of how to use them. The `Convert to Text` command converts the provided value to a text (string) format. Examples: - `123...

Lists

Twidget offers a variety of commands to help you manipulate lists easily without coding. Below is a detailed explanation of each command available. Transform a list. In an endpoint, server function or event, add a command and choose List. Use the commands below to select, reshape, order or combine i...

Conditionals

Condition Command. The Condition Command allows you to perform actions based on whether an expression evaluates to true or false. You can nest other commands within the true or false branches of the condition, enabling complex logic flows. - Expression Builder: Validate two variables to equal true. ...

Math

Twidget offers a variety of commands to manipulate numbers. Below are the math commands available, along with their descriptions, inputs, and outputs. Sum. Description: Adds together a list of numbers and returns the sum. - Inputs: - `numbers`: A list of numbers to be added together. - Output: A sin...