选择您的 Cookie 首选项

我们使用必要 Cookie 和类似工具提供我们的网站和服务。我们使用性能 Cookie 收集匿名统计数据,以便我们可以了解客户如何使用我们的网站并进行改进。必要 Cookie 无法停用,但您可以单击“自定义”或“拒绝”来拒绝性能 Cookie。

如果您同意,AWS 和经批准的第三方还将使用 Cookie 提供有用的网站功能、记住您的首选项并显示相关内容,包括相关广告。要接受或拒绝所有非必要 Cookie,请单击“接受”或“拒绝”。要做出更详细的选择,请单击“自定义”。

步骤 6:使用机器人

聚焦模式
步骤 6:使用机器人 - Amazon Lex V1

终止支持通知:2025年9月15日, AWS 我们将停止对Amazon Lex V1的支持。2025 年 9 月 15 日之后,您将无法再访问亚马逊 Lex V1 主机或 Amazon Lex V1 资源。如果您使用的是 Amazon Lex V2,请改为参阅 Amazon Lex V2 指南

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

终止支持通知:2025年9月15日, AWS 我们将停止对Amazon Lex V1的支持。2025 年 9 月 15 日之后,您将无法再访问亚马逊 Lex V1 主机或 Amazon Lex V1 资源。如果您使用的是 Amazon Lex V2,请改为参阅 Amazon Lex V2 指南

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

出于演示目的,您以客户和客服的身份向机器人提供输入。为了区分两者,客户提出的问题以“客户:”开头,客服提供的答案以“客服:”开头。您可以从建议的输入菜单中进行选择。

打开 index.html 并与机器人进行类似于下图的对话来运行您的 Web 应用程序:

与呼叫中心机器人的两个对话示例。在第一篇文章中,客户询问什么是亚马逊 SageMaker 人工智能,以及何时使用Amazon Polly代替Amazon Lex。在第二个对话中,Amazon Kendra 找到了这两个问题的常见问题答案。

index.html 文件中的 pushChat() 函数说明如下。

var endConversationStatement = "Customer: I have no more questions. Thank you." // If the agent has to send a message, start the message with 'Agent' var inputText = document.getElementById('input'); if (inputText && inputText.value && inputText.value.trim().length > 0 && inputText.value[0]=='Agent') { showMessage(inputText.value, 'agentRequest','conversation'); inputText.value = ""; } // If the customer has to send a message, start the message with 'Customer' if(inputText && inputText.value && inputText.value.trim().length > 0 && inputText.value[0]=='Customer') { // disable input to show we're sending it var input = inputText.value.trim(); inputText.value = '...'; inputText.locked = true; customerInput = input.substring(2); // Send it to the Lex runtime var params = { botAlias: '$LATEST', botName: 'KendraTestBot', inputText: customerInput, userId: lexUserId, sessionAttributes: sessionAttributes }; showMessage(input, 'customerRequest', 'conversation'); if(input== endConversationStatement){ showMessage('Conversation Ended.','conversationEndRequest','conversation'); } lexruntime.postText(params, function(err, data) { if (err) { console.log(err, err.stack); showMessage('Error: ' + err.message + ' (see console for details)', 'lexError', 'conversation1') } if (data &&input!=endConversationStatement) { // capture the sessionAttributes for the next cycle sessionAttributes = data.sessionAttributes; showMessage(data, 'lexResponse', 'conversation1'); } // re-enable input inputText.value = ''; inputText.locked = false; }); } // we always cancel form submission return false;

当您以客户身份提供输入时,Amazon Lex 运行时 API 会将其发送给 Amazon Lex。

showMessage(daText, senderRequest, displayWindow) 函数在聊天窗口中显示客服和客户之间的对话。Amazon Kendra 建议的响应显示在相邻的窗口中。当客户说 “I have no more questions. Thank you.” 时,对话就结束了

注意:不使用 Amazon Kendra 索引时,请将其删除。

隐私网站条款Cookie 首选项
© 2025, Amazon Web Services, Inc. 或其附属公司。保留所有权利。