本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
将自定义数据添加到 Amazon Q in Connect 会话
Amazon Q in Connect 支持将自定义数据添加到 Amazon Q in Connect 会话,以便用于推动向座席提供的生成式人工智能驱动的解决方案。要使用自定义数据,请先使用 UpdateSessionDataAPI 将其添加到会话中,然后使用添加的数据自定义 AI 提示。
在会话中添加和更新数据
您可以使用 UpdateSessionDataAPI 向会话添加数据。使用以下 AWS CLI 命令示例。
aws qconnect update-session-data \ --assistant-id<YOUR_Q_IN_CONNECT_ASSISTANT_ID>\ --session-id<YOUR_Q_IN_CONNECT_SESSION_ID>\ --data '[ { "key": "productId", "value": { "stringValue": "ABC-123" }}, ]'
由于会话是在客户服务代理在 Connect 中使用 Amazon Connect 和 Amazon Q 时为联系人创建的,因此添加会话数据的一种有用方法是使用流程:使用AWS Lambda 函数区块调用 UpdateSessionDataAPI。此 API 可以向会话添加信息。
您需要执行以下操作:
-
将Amazon Q in Connect数据块添加到流中。它将 Amazon Q in Connect 域与联系人关联,这样 Amazon Connect 就可以搜索知识库以获取实时推荐。
-
将 AWS Lambda 函数数据块放在 Amazon Q in Connect 数据块之后。该 UpdateSessionDataAPI 需要来自 Connect 中的 Amazon Q 的会话 ID。你可以使用 DescribeContactAPI 和与区块关联的 AssistanTid 来检索会话 ID。Amazon Q in Connect
下图显示了两个数据块,先是 Amazon Q in Connect 数据块,然后是 AWS Lambda 函数。
将自定义数据与人工智能提示结合使用
将数据添加到会话后,您可以自定义人工智能提示,以使用这些数据来获得生成式人工智能结果。
您可以使用以下格式为数据指定自定义变量:
-
{{$.Custom.<KEY>}}
例如,假设客户需要与特定产品相关的信息。您可以创建查询重构人工智能提示,该提示使用客户在会话期间提供的 productId。
以下来自人工智能提示的摘录显示 {{$.Custom.productId}} 正在提供给 LLM。
anthropic_version: bedrock-2023-05-31 system: You are an intelligent assistant that assists with query construction. messages: - role: user content: | Here is a conversation between a customer support agent and a customer <conversation> {{$.transcript}} </conversation> And here is the productId the customer is contacting us about <productId> {{$.Custom.productId}} </productId> Please read through the full conversation carefully and use it to formulate a query to find a relevant article from the company's knowledge base to help solve the customer's issue. Think carefully about the key details and specifics of the customer's problem. In <query> tags, write out the search query you would use to try to find the most relevant article, making sure to include important keywords and details from the conversation. The more relevant and specific the search query is to the customer's actual issue, the better. If a productId is specified, incorporate it in the query constructed to help scope down search results. Use the following output format <query>search query</query> and don't output anything else.
如果自定义变量的值在会话中不可用,Amazon Q in Connect 会将其内插为空字符串。我们建议在人工智能提示中提供说明,以便系统考虑是否存在任何回退行为的值。