> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Text Message

> Send text chat messages with optional tags, metadata, mentions, and replies.

Use text messages for standard chat content. All SDKs support creating text messages by `subChannelId`; optional fields such as `tags`, `metadata`, `mentionees`, and `parentId` are available through platform-specific payloads or builders.

## Parameters

| Parameter                     | Required | Description                                                                     |
| ----------------------------- | -------- | ------------------------------------------------------------------------------- |
| `subChannelId`                | Yes      | Target subchannel where the text message will be created.                       |
| `text`                        | Yes      | Plain text content for the message.                                             |
| `tags`                        | No       | App-defined tags that can be used by message queries.                           |
| `metadata`                    | No       | App-defined JSON-style metadata stored with the message.                        |
| `mentionees` / `mentionUsers` | No       | Users mentioned by the text message when the platform exposes mention builders. |
| `parentId`                    | No       | Parent message ID when the text message is a reply.                             |

## Basic Text Message

Create a basic text message with a `subChannelId` and text body.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { MessageRepository } from '@amityco/ts-sdk';

  const { data: message } = await MessageRepository.createMessage({
    subChannelId,
    dataType: 'text',
    data: {
      text: 'Welcome to the channel',
    },
  });

  renderResults(message);
  ```

  ```swift iOS theme={null}
  let options = AmityTextMessageCreateOptions(
      subChannelId: "sub-channel-id",
      text: "Welcome to the channel"
  )

  let message = try await messageRepository.createTextMessage(options: options)
  showSuccessMessage(message.messageId)
  ```

  ```kotlin Android theme={null}
  val disposable = AmityChatClient.newMessageRepository()
      .createTextMessage(
          subChannelId = subChannelId,
          text = "Welcome to the channel",
      )
      .build()
      .send()
      .subscribe(
          { showSuccessMessage() },
          { error -> handleGeneralError(error) },
      )
  ```

  ```dart Flutter theme={null}
  final message = await AmityChatClient.newMessageRepository()
      .createMessage(subChannelId)
      .text('Welcome to the channel')
      .send();

  final messageId = message.messageId;
  ```
</CodeGroup>

## Text With Context

Add tags, metadata, mentions, or reply context when the text message needs extra app-owned behavior.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { MessageRepository } from '@amityco/ts-sdk';

  const { data: message } = await MessageRepository.createMessage({
    subChannelId,
    dataType: 'text',
    data: {
      text: 'Please review this update',
    },
    tags: ['announcement'],
    metadata: {
      source: 'composer',
    },
    mentionees: [{ type: 'user', userIds: [userId] }],
  });
  ```

  ```swift iOS theme={null}
  let metadata: [String: Any] = [
      "source": "composer"
  ]

  let options = AmityTextMessageCreateOptions(
      subChannelId: "sub-channel-id",
      text: "Please review this update",
      tags: ["announcement"],
      metadata: metadata
  )

  let message = try await messageRepository.createTextMessage(options: options)
  showSuccessMessage(message.messageId)
  ```

  ```kotlin Android theme={null}
  val metadata = JsonObject().apply {
      addProperty("source", "composer")
  }

  val disposable = AmityChatClient.newMessageRepository()
      .createTextMessage(
          subChannelId = subChannelId,
          text = "Please review this update",
      )
      .tags(AmityTags(listOf("announcement")))
      .metadata(metadata)
      .mentionUsers(listOf(userId))
      .build()
      .send()
      .subscribe()
  ```

  ```dart Flutter theme={null}
  final message = await AmityChatClient.newMessageRepository()
      .createMessage(subChannelId)
      .text('Please review this update')
      .tags(['announcement'])
      .metadata({'source': 'composer'})
      .mentionUsers([userId])
      .send();
  ```
</CodeGroup>

## Related Topics

<CardGroup cols={2}>
  <Card title="Reply to a Message" href="./reply-to-a-message" icon="reply">
    Create a text reply with `parentId`.
  </Card>

  <Card title="Query Messages" href="../messages/query-and-filter-messages" icon="list-filter">
    Query text messages and reply threads.
  </Card>
</CardGroup>
