Rooms messages send

Open in

Use the ably rooms messages send command to send a message to an Ably Chat room.

Synopsis

ably rooms messages send <room-name> <text> [options]

Arguments

room-name
Required

The name of the chat room to send the message to.

text
Required

The text content of the message.

Options

--count | -c

The number of messages to send. Defaults to 1.

--delay | -d

The delay between messages in milliseconds when sending multiple messages. Defaults to 40.

--metadata

A JSON string of metadata to attach to the message.

--client-id

A client ID to use when sending the message.

--json

Output results as compact JSON. Mutually exclusive with --pretty-json.

--pretty-json

Output results in formatted JSON. Mutually exclusive with --json.

--verbose | -v

Enable verbose logging. Can be combined with --json or --pretty-json.

Examples

Send a message to a chat room:

ably rooms messages send my-room "Hello, world!"

Send multiple messages with interpolation:

ably rooms messages send my-room "Message {{.Count}} at {{.Timestamp}}" --count 10

Send a message with metadata:

ably rooms messages send my-room "Hello" --metadata '{"priority": "high"}'

Send messages at a controlled rate with timestamps:

ably rooms messages send --count 10 --delay 1000 my-room "Message at {{.Timestamp}}"

Send a room message using an API key environment variable:

ABLY_API_KEY="YOUR_API_KEY" ably rooms messages send my-room "Welcome to the chat!"

Send a room message and output the result in JSON format:

ably rooms messages send my-room "Hello World!" --json

Send a room message and output the result in formatted JSON:

ably rooms messages send my-room "Hello World!" --pretty-json

See also

  • Rooms — Explore all ably rooms commands.
  • CLI reference — Full list of available commands.