

终止支持通知：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`、`PostText` 或 `PutSession` 操作来设置上下文。  
您可以使用上下文来控制可以跟进意图的意图，也可以修改应用程序的操作。  
类型：[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>
代表会话特定上下文信息的 key/value 对映射。它包含在 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>

有关以特定语言之一使用此 API 的更多信息 AWS SDKs，请参阅以下内容：
+  [AWS 命令行界面 V2](https://docs.aws.amazon.com/goto/cli2/runtime.lex-2016-11-28/GetSession) 
+  [AWS 适用于.NET 的 SDK V4](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 v2 的 SDK](https://docs.aws.amazon.com/goto/SdkForGoV2/runtime.lex-2016-11-28/GetSession) 
+  [AWS 适用于 Java 的 SDK V2](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 的 SDK V3](https://docs.aws.amazon.com/goto/SdkForPHPV3/runtime.lex-2016-11-28/GetSession) 
+  [AWS Python 软件开发工具包](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) 