在从 Lex 调用的 Lambda 函数中,我们需要知道请求是来自 Connect 还是来自控制台或其他聊天工具等文本源。
我们主要需要知道这一点来决定是否需要使用纯文本或 SSML 进行响应。
在从 Lex 调用的 Lambda 函数中,我们需要知道请求是来自 Connect 还是来自控制台或其他聊天工具等文本源。
我们主要需要知道这一点来决定是否需要使用纯文本或 SSML 进行响应。
您需要查看 request 属性x-amz-lex:accept-content-types
。例如,在 Node.js 函数中,您可以这样做:
function canUseSSML(event) {
if (event.requestAttributes) {
if(event.requestAttributes['x-amz-lex:accept-content-types'] && event.requestAttributes['x-amz-lex:accept-content-types'].indexOf('SSML') != -1) {
return true;
}
}
return false;
}