gpt4 book ai didi

amazon-web-services - Lambda 函数将 Lex 引导至新意图

转载 作者:行者123 更新时间:2023-12-03 19:33:23 24 4
gpt4 key购买 nike

我正在尝试使用 lambda 函数根据传入插槽的值将 lex 发送到新意图:

像这样

 public override LexResponse Process(LexEvent lexEvent, ILambdaContext context)
{
var slots = lexEvent.CurrentIntent.Slots;
var sessionAttributes = lexEvent.SessionAttributes ?? new Dictionary<string, string>();
DesiredVehicleYesNo type;
if (slots.ContainsKey("DesiredVehicleYesNo"))
{
Enum.TryParse(slots["DesiredVehicleYesNo"], out type);
}
else
{
type = DesiredVehicleYesNo.Null;
}

switch (type)
{
case DesiredVehicleYesNo.YES:
Dictionary<string, string> s = new Dictionary<string, string>();
s.Add("DesiredVehicle", null);
//return ConfirmIntent(sessionAttributes, "DesiredVehicleYes", s, new LexResponse.LexMessage() { Content = "That's great! Let's get started.", ContentType = MESSAGE_CONTENT_TYPE });
//return ElicitSlot(sessionAttributes,"DesiredVehicleYes",null,"DesiredVehicle", new LexResponse.LexMessage() { Content = "That's great! Let's get started.", ContentType = MESSAGE_CONTENT_TYPE });

case DesiredVehicleYesNo.NO:
return ConfirmIntent(sessionAttributes, "DesiredVehicleNo", new Dictionary<string,string>(), new LexResponse.LexMessage() { Content = "Well, that's ok, I can help you choose", ContentType = MESSAGE_CONTENT_TYPE });

}

我只是不确定我应该为此使用什么返回类型? ConfirmIntent、ElicitSlot、ElicitIntent?此外,我确实需要将插槽传回,我希望新意图使用它自己的提示来填充与该意图相关的插槽。

谢谢

最佳答案

您应该使用 ConfirmIntent并供应 intentNameslots您要切换到的意图。

Lex Response Format Docs

ConfirmIntent — Informs Amazon Lex that the user is expected to give a yes or no answer to confirm or deny the current intent.
You must include the intentName and slots fields. The slots field must contain an entry for each of the slots configured for the specified intent. If the value of a slot is unknown, you must set it to null. You must include the message field if the intent's confirmationPrompt field is null. If you specify both the message field and the confirmationPrompt field, the response includes the contents of the confirmationPrompt field. The responseCard field is optional.



因此,您可以提供自己的信息,但请确保将其写为是/否问题。因为 ConfirmIntent将期待用户的 Yes/No 响应。

此方法将始终触发您在 intentName 中提供的意图.所以你必须在那里处理用户的响应。
如果用户说"is",那么 confirmationStatus将持有值 Confirmed .
如果用户说“不”,那么 confirmationStatus将持有值 Denied .

确保您传回的插槽对于该新意图是正确的。你可以通过它们预先填充来使用用户已经给你的东西;或设置为 null允许新意图要求用户再次填充这些插槽。

关于amazon-web-services - Lambda 函数将 Lex 引导至新意图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52073753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com