终止支持通知:2025年9月15日, AWS 我们将停止对Amazon Lex V1的支持。2025 年 9 月 15 日之后,您将无法再访问亚马逊 Lex V1 主机或 Amazon Lex V1 资源。如果您使用的是 Amazon Lex V2,请改为参阅 Amazon Lex V2 指南。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
要验证自动程序能否正确处理文本输入,请使用 PostText 操作。要运行本练习中的命令,您需要知道将在其中运行命令的区域。有关区域列表,请参阅运行时服务配额。
注意
以下 AWS CLI 示例是针对 Unix、Linux 和 macOS 进行格式化的。对于 Windows,请将 "\$LATEST"
更改为 $LATEST
并将每行末尾的反斜杠 (\) 继续符替换为脱字号 (^)。
使用文本测试自动程序 (AWS CLI)
-
在中 AWS CLI,开始与
OrderFlowersBot
机器人对话。此示例的格式适用于 Unix、Linux 和 macOS。对于 Windows,请将每行末尾的反斜杠 (\) Unix 行继续符替换为脱字号 (^)。aws lex-runtime post-text \ --region
region
\ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "i would like to order flowers"Amazon Lex 识别用户意图并通过返回以下响应开始对话:
{ "slotToElicit": "FlowerType", "slots": { "PickupDate": null, "PickupTime": null, "FlowerType": null }, "dialogState": "ElicitSlot", "message": "What type of flowers would you like to order?", "intentName": "OrderFlowers" }
-
运行以下命令以完成与自动程序的对话。
aws lex-runtime post-text \ --region
region
\ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "roses"aws lex-runtime post-text \ --region
region
\ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "tuesday"aws lex-runtime post-text \ --region
region
\ --bot-name OrderFlowersBot --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "10:00 a.m."aws lex-runtime post-text \ --region
region
\ --bot-name OrderFlowersBot \ --bot-alias "\$LATEST" \ --user-id UserOne \ --input-text "yes"在您确认订单后,Amazon Lex 会发送一个履行响应以完成对话:
{ "slots": { "PickupDate": "2017-05-16", "PickupTime": "10:00", "FlowerType": "roses" }, "dialogState": "ReadyForFulfillment", "intentName": "OrderFlowers" }