本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
向 AI 代理会话中添加客户数据
Connect Customer 支持向 AI 代理会话添加自定义数据,以便可以将其用于驱动生成式 AI 驱动的解决方案。可以使用自定义数据,首先使用 UpdateSessionData API 将其添加到会话中,然后使用添加的数据自定义 AI 提示。
在会话中添加和更新数据
您可以使用 UpdateSessionData API 向会话添加数据。使用以下 AWS CLI 命令示例。
aws qconnect update-session-data \ --assistant-id<YOUR_CONNECT_AI_AGENT_ASSISTANT_ID>\ --session-id<YOUR_CONNECT_AI_AGENT_SESSION_ID>\ --data '[ { "key": "productId", "value": { "stringValue": "ABC-123" }}, ]'
由于会话是为联系人创建的,因此添加会话数据的一种有用方法是使用流程:使用AWS Lambda 函数区块调用 UpdateSessionData API。此 API 可以向会话添加信息。
您需要执行以下操作:
-
将连接助手数据块添加到流中。它将 AI 代理域与联系人关联起来,这样 Connect 客户就可以在知识库中搜索实时推荐。
-
将 AWS Lambda 函数数据块放在 连接助手 数据块之后。该 UpdateSessionData API 需要会话 ID。你可以使用 DescribeContact API 和与区块关联的 Assistant ID 来检索会话 ID。连接助手
下图显示了两个数据块,先是 连接助手 数据块,然后是 AWS Lambda 函数。
将自定义数据与人工智能提示结合使用
将数据添加到会话后,您可以自定义人工智能提示,以使用这些数据来获得生成式人工智能结果。
您可以使用以下格式为数据指定自定义变量:
-
{{$.Custom.<KEY>}}
例如,假设客户需要与特定产品相关的信息。您可以创建查询重构人工智能提示,该提示使用客户在会话期间提供的 productId。
以下 AI 提示的摘录显示 {{$.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.
如果自定义变量的值在会话中不可用,则将其插值为空字符串。我们建议在人工智能提示中提供说明,以便系统考虑是否存在任何回退行为的值。