

支援終止通知：2025 年 9 月 15 日， AWS 將停止對 Amazon Lex V1 的支援。2025 年 9 月 15 日之後，您將無法再存取 Amazon Lex V1 主控台或 Amazon Lex V1 資源。如果您使用的是 Amazon Lex V2，請改參閱 [Amazon Lex V2 指南](https://docs.aws.amazon.com/lexv2/latest/dg/what-is.html)。

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

# GetSession
<a name="API_runtime_GetSession"></a>

傳回指定機器人、別名和使用者 ID 的工作階段資訊。

## 請求語法
<a name="API_runtime_GetSession_RequestSyntax"></a>

```
GET /bot/botName/alias/botAlias/user/userId/session/?checkpointLabelFilter=checkpointLabelFilter HTTP/1.1
```

## URI 請求參數
<a name="API_runtime_GetSession_RequestParameters"></a>

請求會使用下列 URI 參數。

 ** [botAlias](#API_runtime_GetSession_RequestSyntax) **   <a name="lex-runtime_GetSession-request-uri-botAlias"></a>
用於包含工作階段資料的機器人的別名。  
必要：是

 ** [botName](#API_runtime_GetSession_RequestSyntax) **   <a name="lex-runtime_GetSession-request-uri-botName"></a>
包含工作階段資料的機器人名稱。  
必要：是

 ** [checkpointLabelFilter](#API_runtime_GetSession_RequestSyntax) **   <a name="lex-runtime_GetSession-request-uri-checkpointLabelFilter"></a>
用來篩選`recentIntentSummaryView`結構中傳回之意圖的字串。  
當您指定篩選條件時，只會傳回 `checkpointLabel` 欄位設定為該字串的意圖。  
長度限制：長度下限為 1。長度上限為 255。  
模式：`[a-zA-Z0-9-]+`

 ** [userId](#API_runtime_GetSession_RequestSyntax) **   <a name="lex-runtime_GetSession-request-uri-userId"></a>
用戶端應用程式使用者的 ID。Amazon Lex 使用此項目來識別使用者與您的機器人的對話。  
長度限制：長度下限為 2。長度上限為 100。  
模式：`[0-9a-zA-Z._:-]+`  
必要：是

## 請求主體
<a name="API_runtime_GetSession_RequestBody"></a>

請求沒有請求主體。

## 回應語法
<a name="API_runtime_GetSession_ResponseSyntax"></a>

```
HTTP/1.1 200
Content-type: application/json

{
   "activeContexts": [ 
      { 
         "name": "string",
         "parameters": { 
            "string" : "string" 
         },
         "timeToLive": { 
            "timeToLiveInSeconds": number,
            "turnsToLive": number
         }
      }
   ],
   "dialogAction": { 
      "fulfillmentState": "string",
      "intentName": "string",
      "message": "string",
      "messageFormat": "string",
      "slots": { 
         "string" : "string" 
      },
      "slotToElicit": "string",
      "type": "string"
   },
   "recentIntentSummaryView": [ 
      { 
         "checkpointLabel": "string",
         "confirmationStatus": "string",
         "dialogActionType": "string",
         "fulfillmentState": "string",
         "intentName": "string",
         "slots": { 
            "string" : "string" 
         },
         "slotToElicit": "string"
      }
   ],
   "sessionAttributes": { 
      "string" : "string" 
   },
   "sessionId": "string"
}
```

## 回應元素
<a name="API_runtime_GetSession_ResponseElements"></a>

如果動作成功，則服務傳回 HTTP 200 回應。

服務會傳回下列 JSON 格式的資料。

 ** [activeContexts](#API_runtime_GetSession_ResponseSyntax) **   <a name="lex-runtime_GetSession-response-activeContexts"></a>
工作階段的作用中內容清單。滿足意圖或呼叫 `PostContent`、 或 `PutSession`操作時`PostText`，可以設定內容。  
您可以使用內容來控制可追蹤意圖的意圖，或修改應用程式的操作。  
類型：[ActiveContext](API_runtime_ActiveContext.md) 物件陣列  
陣列成員：項目數下限為 0。項目數上限為 20。

 ** [dialogAction](#API_runtime_GetSession_ResponseSyntax) **   <a name="lex-runtime_GetSession-response-dialogAction"></a>
描述機器人的目前狀態。  
類型：[DialogAction](API_runtime_DialogAction.md) 物件

 ** [recentIntentSummaryView](#API_runtime_GetSession_ResponseSyntax) **   <a name="lex-runtime_GetSession-response-recentIntentSummaryView"></a>
有關工作階段中所用意圖的資訊陣列。陣列最多可包含三個摘要。如果在工作階段中使用超過三個意圖，`recentIntentSummaryView`操作會包含最後三個使用意圖的相關資訊。  
如果您在請求中設定 `checkpointLabelFilter` 參數，則陣列只會包含具有指定標籤的意圖。  
類型：[IntentSummary](API_runtime_IntentSummary.md) 物件陣列  
陣列成員：項目數下限為 0。最多 3 個項目。

 ** [sessionAttributes](#API_runtime_GetSession_ResponseSyntax) **   <a name="lex-runtime_GetSession-response-sessionAttributes"></a>
代表工作階段特定內容資訊的鍵/值對映射。它包含 Amazon Lex 和用戶端應用程式之間傳遞的應用程式資訊。  
類型：字串到字串映射

 ** [sessionId](#API_runtime_GetSession_ResponseSyntax) **   <a name="lex-runtime_GetSession-response-sessionId"></a>
工作階段的唯一識別碼。  
類型：字串

## 錯誤
<a name="API_runtime_GetSession_Errors"></a>

 ** BadRequestException **   
 請求驗證失敗、內容中沒有可用的訊息，或機器人建置失敗、仍在進行中，或包含未建置的變更。  
HTTP 狀態碼：400

 ** InternalFailureException **   
內部服務錯誤。重試 呼叫。  
HTTP 狀態碼：500

 ** LimitExceededException **   
超過限制。  
HTTP 狀態碼：429

 ** NotFoundException **   
找不到參考的資源 （例如 Amazon Lex 機器人或別名）。  
HTTP 狀態碼：404

## 另請參閱
<a name="API_runtime_GetSession_SeeAlso"></a>

如需在其中一種語言特定 AWS SDKs中使用此 API 的詳細資訊，請參閱下列內容：
+  [AWS 命令列界面 V2](https://docs.aws.amazon.com/goto/cli2/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 .NET V4 的 SDK](https://docs.aws.amazon.com/goto/DotNetSDKV4/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 C\$1\$1 的 SDK](https://docs.aws.amazon.com/goto/SdkForCpp/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 Go 的 SDK v2](https://docs.aws.amazon.com/goto/SdkForGoV2/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 Java V2 的 SDK](https://docs.aws.amazon.com/goto/SdkForJavaV2/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 JavaScript V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForJavaScriptV3/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 Kotlin 的 SDK](https://docs.aws.amazon.com/goto/SdkForKotlin/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 PHP V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForPHPV3/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 Python 的 SDK](https://docs.aws.amazon.com/goto/boto3/runtime.lex-2016-11-28/GetSession) 
+  [AWS 適用於 Ruby V3 的 SDK](https://docs.aws.amazon.com/goto/SdkForRubyV3/runtime.lex-2016-11-28/GetSession) 