我正在遵循从Interactions开始的指南。当我在交互上调用该send
方法时,出现以下错误:
(节点:27796)UnhandledPromiseRejectionWarning:MissingRequiredParameter:参数中缺少必需的键“userId”
看起来 Interactions 期待一个userId参数,它@aws-amplify/interactions/lib/Providers/AWSLexProvider.js
应该从credentials.identityId
. 但是,当我登录时credentials
,它是 type ,根据文档SharedIniFileCredentials
它没有identityId
属性。
通过阅读文档,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();
那么我在这里错过了什么?