【发布时间】:2019-01-11 14:31:22
【问题描述】:
我遵循从Interactions 开始的指南。当我在 Interactions 上调用 send 方法时,出现以下错误:
(节点:27796)UnhandledPromiseRejectionWarning:MissingRequiredParameter:参数中缺少必需的键“userId”
Interactions 似乎需要一个 userId 参数,该参数在 @aws-amplify/interactions/lib/Providers/AWSLexProvider.js 中应该是从 credentials.identityId 中提取的。但是,当我登录credentials 时,它是类型SharedIniFileCredentials,它没有identityId 属性according to the documentation。
来自reading the docs,identityId 必须是 Cognito 用户。 AWSLexProvider.js 不会尝试调用 CognitoIdentityCredentials 来获取 Cognito 凭据。
因此,我不确定identityId 应该来自哪里。
我的代码是来自 Amplify 网站的示例:
import Amplify, { Interactions } from 'aws-amplify';
import aws_exports from './aws-exports';
Amplify.configure(aws_exports);
async function test() {
let userInput = "I want to reserve a hotel for tonight";
// Provide a bot name and user input
const response = await Interactions.send("BookTrip", userInput);
// Log chatbot response
console.log (response['message']);
}
test();
那么我在这里错过了什么?
【问题讨论】:
-
有同样的问题。如果您知道如何解决它,请告诉我?
标签: amazon-web-services aws-sdk amazon-lex aws-amplify amplifyjs