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

# Reply or send messages with a bot

> Describes two ways for a bot to reply or proactively send messages: sending via webhook and sending via the server-side API.

If you need to implement bot reply or bot message sending, follow the steps in this document to develop bot reply or bot message sending.

## Background

Replying to a message with a bot is essentially the same process as sending a message with a bot. Therefore, in this document, replying and sending have the same meaning.

Messages can be sent through either the Server API or a Webhook. The following sections introduce both methods.

## Prerequisites

1. Complete the [Create an app](/open/dingstart/create-application) process.
2. Complete the process of adding app capabilities.

## Send messages through a Webhook

### Send messages through a Webhook

<Note>
  Sending messages through a webhook supports the @ feature. See the integration example below for details.
</Note>

1. Send messages through the app bot Webhook URL:

   1. In [Bot receives messages](/open/dingstart/robot-receive-message), obtain the Webhook URL of the app bot in the group. For details, see [Obtain the app bot Webhook](/open/development/faq-robot).
   2. Java development environment setup:

      * Import the Java SDK. For SDKs in other languages, see the legacy Server-side SDK download.

        ```xml lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>alibaba-dingtalk-service-sdk</artifactId>
            <version>2.0.0</version>
        </dependency>
        ```
   3. Integration code example:

      ```java lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
      public void sendMessageWebhook() throws ApiException {
              DingTalkClient client = new DefaultDingTalkClient("{ Webhook url }");
              OapiRobotSendRequest request = new OapiRobotSendRequest();
              request.setMsgtype("text");
              OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
              text.setContent("Test text message");
              request.setText(text);
              OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
              at.setAtUserIds(Arrays.asList("4525xxxxxxxxx7041"));
              at.setIsAtAll(false);
              request.setAt(at);
              OapiRobotSendResponse response = client.execute(request);
              System.out.println(response.getBody());
      }
      ```

      For more message types, see the message types supported by Custom bot message sending.
2. Send messages through the sessionWebhook field returned when the bot receives a message.

   1. Obtain the sessionWebhook URL from the JSON data returned in [Bot receives messages](/open/dingstart/robot-receive-message).
   2. Java development environment setup:

      * Import the Java SDK. For SDKs in other languages, see the legacy Server-side SDK download.

        ```xml lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
        <dependency>
            <groupId>com.aliyun</groupId>
            <artifactId>alibaba-dingtalk-service-sdk</artifactId>
            <version>2.0.0</version>
        </dependency>
        ```
   3. Integration code example:

      ```java lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
      public void sendMessageWebhook() throws ApiException {
              DingTalkClient client = new DefaultDingTalkClient("{ SessionWebhook url }");
              OapiRobotSendRequest request = new OapiRobotSendRequest();
              request.setMsgtype("text");
              OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
              text.setContent("Test text message");
              request.setText(text);
              OapiRobotSendRequest.At at = new OapiRobotSendRequest.At();
              at.setAtUserIds(Arrays.asList("4525xxxxxxxxx7041"));
              at.setIsAtAll(false);
              request.setAt(at);
              OapiRobotSendResponse response = client.execute(request);
              System.out.println(response.getBody());
      }
      ```

      For more message types, see the message types supported by Custom bot message sending.

## Send messages through the Server API

The following table lists the Server APIs for sending messages. For more API details, see [Bot Server API](/open/development/development-robot-overview).

| **API name**                                                                                                                                 | **Description**                                                                                                                        |
| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| [Bot sends group chat messages](/open/development/the-robot-sends-a-group-message)                                                           | Send messages in a group. The @ feature is not supported yet.                                                                          |
| [Send bot messages in one-on-one chats in batches](/open/development/chatbots-send-one-on-one-chat-messages-in-batches)                      | Send messages in person-to-bot chats. The @ feature is not supported yet.                                                              |
| [Bot sends plain messages in person-to-person chats](/open/development/the-robot-sends-ordinary-messages-in-a-person-to-person-conversation) | Send messages in person-to-person chats. The @ feature is not supported yet.  **Note**  Use only in Direct Message Cool App scenarios. |

For details on calling the Server API, see the document on how to call the Server API.

## Next steps

After bot message sending development is complete, publish the app.
