

**支援終止通知**：在 2026 年 2 月 20 日， AWS 將終止對 Amazon Chime 服務的支援。2026 年 2 月 20 日之後，您將無法再存取 Amazon Chime 主控台或 Amazon Chime 應用程式資源。如需詳細資訊，請造訪[部落格文章](https://aws.amazon.com/blogs/messaging-and-targeting/update-on-support-for-amazon-chime/)。**注意：**這不會影響 [Amazon Chime SDK 服務的](https://aws.amazon.com/chime/chime-sdk/)可用性。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 步驟 2：設定 Amazon Chime 聊天機器人的傳出端點
<a name="config-endpoints"></a>

為您的 Amazon Chime Enterprise 帳戶建立聊天機器人 ID 之後，請設定您的傳出端點，讓 Amazon Chime 使用 將訊息傳送到您的機器人。傳出端點可以是 AWS Lambda 函數 ARN 或 HTTPS 端點，這是您在[先決條件](use-bots.md#bots-prereqs)中建立的。如需有關 Lambda 的詳細資訊，請參閱 *[AWS Lambda 開發人員指南](https://docs.aws.amazon.com/lambda/latest/dg/)*。

**注意**  
如果您的機器人的傳出 HTTPS 端點未設定或為空，聊天室管理員無法將機器人新增至聊天室。此外，聊天室使用者無法與機器人互動。

## AWS CLI
<a name="endpoint-cli"></a>

若要設定聊天機器人的傳出端點，請在 中使用 **put-events-configuration**命令 AWS CLI。設定 Lambda 函數 ARN 或傳出 HTTPS 端點。

------
#### [ Lambda ARN ]

```
aws chime put-events-configuration --account-id 12a3456b-7c89-012d-3456-78901e23fg45 --bot-id botId --lambda-function-arn arn:aws:lambda:us-east-1:111122223333:function:function-name
```

------
#### [ HTTPS endpoint ]

```
aws chime put-events-configuration --account-id 12a3456b-7c89-012d-3456-78901e23fg45 --bot-id botId --outbound-events-https-endpoint https://example.com:8000
```

------

Amazon Chime 會以機器人 ID 和 HTTPS 端點回應。

```
{
    "EventsConfiguration": {
        "BotId": "BotId", 
        "OutboundEventsHTTPSEndpoint": "https://example.com:8000"
    }
}
```

## Amazon Chime API
<a name="endpoint-api"></a>

若要設定聊天機器人的傳出端點，請使用 Amazon Chime API 參考中的 Amazon Chime [PutEventsConfiguration](https://docs.aws.amazon.com/chime/latest/APIReference/API_PutEventsConfiguration.html) API 操作。 **設定 Lambda 函數 ARN 或傳出 HTTPS 端點。
+ **如果您設定 Lambda 函數 ARN** – Amazon Chime 呼叫 Lambda 以新增許可，以允許 Amazon Chime 管理員 AWS 的帳戶叫用提供的 Lambda 函數 ARN。然後是乾執行調用，以確認 Amazon Chime 具有調用函數的許可。如果新增許可失敗，或乾執行調用失敗，則`PutEventsConfiguration`請求會傳回 HTTP 4xx 錯誤。
+ **如果您設定傳出 HTTPS 端點** – Amazon Chime 透過傳送 HTTP Post 請求與挑戰 JSON 承載到您在上一個步驟中提供的傳出 HTTPS 端點，來驗證您的端點。您的傳出 HTTPS 端點必須回應，傳回 JSON 格式的 Challenge 參數。以下範例顯示請求和有效的回應。

------
#### [ Request ]

  ```
                 HTTPS POST 
  
                 JSON Payload:
                 {
                    "Challenge":"00000000000000000000",
                    "EventType" : "HTTPSEndpointVerification"
                 }
  ```

------
#### [ Response ]

  ```
                 HTTP/1.1 200 OK
                 Content-type: application/json
  
                 {
                     "Challenge":"00000000000000000000"
                 }
  ```

------

  如果挑戰交握失敗，則 `PutEventsConfiguration` 請求將傳回 HTTP 4xx 錯誤。

## AWS 適用於 Java 的開發套件
<a name="endpoint-sdk"></a>

下列範例程式碼示範如何使用適用於 Java 的 AWS SDK 設定端點。

```
PutEventsConfigurationRequest putEventsConfigurationRequest = new PutEventsConfigurationRequest()
     .withAccountId("chimeAccountId")
     .withBotId("botId")
     .withOutboundEventsHTTPSEndpoint("https://www.example.com")
     .withLambdaFunctionArn("arn:aws:lambda:region:account-id:function:function-name");

 chime.putEventsConfiguration(putEventsConfigurationRequest):
```