> For the complete documentation index, see [llms.txt](https://tools.docs.sendbird.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tools.docs.sendbird.com/readme/chat/send-and-receive-messages.md).

# Send and receive messages

Send a message as Alice in an [Open channel](/readme/chat.md#terms-used-in-these-tutorials) and check that Bob receives it.

## Before you begin

Complete [Create test users](/readme/chat/create-test-users.md), and keep terminal A and terminal B open. Commands run against the app that's selected now. If you selected another app since then, [select your test app](/readme/quickstart.md#step-3-select-your-app) again.

## Step 1. Create the channel

In terminal A, create a channel:

```bash
sendbird --profile prod --json chat channel create --type open --name 'Tutorial open'
```

`--json` prints the full response, so you can copy values from it. The response includes the channel's `result.channel_url`. Copy that value. In the following commands, replace `<CHANNEL_URL>` with it, without the angle brackets.

## Step 2. Start Bob's receiver

In terminal B, start watching the channel as Bob:

```bash
sendbird --profile prod chat channel watch --type open --id <CHANNEL_URL> \
  --seconds 120 --max-events 100 --as-user tutorial_bob
```

The `watch` command prints one line for each event. It stops after two minutes or 100 events, whichever comes first. Wait for the line that starts with `• ready`:

```
• ready · sendbird_open_channel_27588_0b86f5967ac7060e72ba6c6684c77d117494ad2a
```

Keep the watch running. Switch to terminal A before it stops. If it stops before you send the message, run it again.

## Step 3. Send as Alice

In terminal A, send a message:

```bash
sendbird --profile prod chat message send --type open --id <CHANNEL_URL> \
  --message 'Hello from Alice' --as-user tutorial_alice
```

The output starts with `✓ Sent message` followed by the message ID. Copy the message ID. In Step 4, replace `<MESSAGE_ID>` with it, without the angle brackets.

In terminal B, a `message received` line appears. The message ID at the end of the line matches the ID in terminal A:

```
• message received · sendbird_open_channel_27588_0b86f5967ac7060e72ba6c6684c77d117494ad2a · message 9359045164
```

Then stop the watch with Ctrl+C.

## Step 4. Read the message back

In terminal A, read the stored message:

```bash
sendbird --profile prod chat message get --type open --id <CHANNEL_URL> \
  --message-id <MESSAGE_ID> --as-user tutorial_alice
```

In the output, **Sender** shows `tutorial_alice`, and **Message** shows `Hello from Alice`.

## Step 5. Clean up

In terminal A, delete the channel, then check that it no longer exists:

```bash
sendbird --profile prod chat channel delete --type open --id <CHANNEL_URL> --yes
sendbird --profile prod chat channel get --type open --id <CHANNEL_URL>
```

The lookup returns `E_NOT_FOUND`. Keep Alice and Bob for the other tutorials, and [delete them](/readme/chat.md#delete-the-test-users) after you finish all the tutorials.

Next, follow [Use Group channel features](/readme/chat/use-group-channel-features.md).
