AWS Lex + Lambda-拦截下一个用户的所有响应,而不受上下文的影响-是否未定义示例话语? [英] AWS Lex + Lambda - Intercepting all of next user response regardless of context - without defining sample utterances?

查看:75
本文介绍了AWS Lex + Lambda-拦截下一个用户的所有响应,而不受上下文的影响-是否未定义示例话语?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请考虑以下情形(U =用户,L = Lex):

Consider the following scenario (U=User, L=Lex):

U1:您好

L1:您好,请给我您的名字以开始使用.

L1: Hello, please give me your name to get started.

U2:鲍勃

L2:Bob,请考虑以下问题:天空是什么颜色?

L2: Bob, consider the following question: What colour is the sky?

U3:天空通常是蓝色的,但有时天空是红色的.

U3: The sky is usually blue but sometimes the sky is red.

系统读取问题数据库,并随机选择一个要呈现给用户的数据库.这是通过AWS Lambda完成的,问题会在消息L2中显示给用户.

The system reads a database of questions and randomly chooses one to present to the user. This is done via AWS Lambda and the question is presented to the user in message L2.

有没有办法说来自用户的下一个答复应被视为他们对问题的答案,而无需定义言语等?这是因为漫游器发送的问题可能会有很大的差异.

Is there any way to say that 'the next response from the user should be treated as their answer to the question without defining utterances etc? This is because the questions that the bot sends across can vary to a great degree.

我需要一种将所有U3块传递回Lambda进行处理的方法.无论背景如何,我将如何实现这一目标?(我将python用于Lambda)

I need a way to pass all of block U3 back to Lambda for processing. How would I achieve this regardless of context? (I am using python for Lambda)

谢谢

推荐答案

Lex始终在 input 字段下的 Request 中传递整个用户的输入.

Lex always passes the entire user's input in the Request under the field inputTranscript.

Lex-Lambda事件格式:

inputTranscript –用于处理请求的文本.

inputTranscript – The text used to process the request.

如果输入是文本,则inputTranscript字段包含用户输入的文本.

If the input was text, the inputTranscript field contains the text that was input by the user.

如果输入是音频流,则inputTranscript字段包含从音频流中提取的文本.这是经过实际处理以识别意图和广告位值的文本.

If the input was an audio stream, the inputTranscript field contains the text extracted from the audio stream. This is the text that is actually processed to recognize intents and slot values.

这是Lambda作为 event 接收到的Lex请求的格式:

This is the format of the Lex Request received by Lambda as event:

{
  "currentIntent": {
    "name": "intent-name",
    "slots": {...},
    "slotDetails": {...},
    "confirmationStatus": "(None, Confirmed, or Denied)"
  },
  "bot": {...},
  "userId": "XXXX",
  "invocationSource": "(FulfillmentCodeHook or DialogCodeHook)",
  "outputDialogMode": "(Text or Voice)",
  "messageVersion": "1.0",
  "sessionAttributes": {...},
  "requestAttributes": {...}
  "inputTranscript": "Text of full user's input utterance",
}

因此,在Lambda中,您可以使用以下命令访问 inputTranscipt :

So in Lambda, you can access the inputTranscipt with:

userInput = event.inputTranscript

这篇关于AWS Lex + Lambda-拦截下一个用户的所有响应,而不受上下文的影响-是否未定义示例话语?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆