gpt4 book ai didi

node.js - 使用 sendUsersMessages(javascript SDK)时,AWS Pinpoint 出现 TemplateConfiguration 错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:51:37 24 4
gpt4 key购买 nike

我正在尝试通过 JavaScript 中的 Lambda 函数使用 Pinpoint 发送消息。我正在关注这个documentation

当我尝试使用模板时,我收到值“TemplateConfiguration”的意外键错误这是我的 lambda 函数:

console.log("Loading function");
const AWS = require('aws-sdk');

exports.handler = (event, context, callback) => {
const applicationId = '53076d18cdf84604a0cfcf513c3d3392';
const userId = '33666';
const name = 'Berunda';
const amount = '$32.33';
const emailTemplateName = 'Claro_Payment';
const smsTemplateName = 'Claro_Payment';
const pushTemplateName = 'Claro_Payment';

const pinpoint = new AWS.Pinpoint();

const params = {
ApplicationId: applicationId,
SendUsersMessageRequest: {
MessageConfiguration: {},
Users: {
[userId]: {
Substitutions: {
name: [name],
amount: [amount]
}
}
},
TemplateConfiguration: {
SMSTemplate: {
Name: smsTemplateName
},
PushTemplate: {
Name: pushTemplateName
},
EmailTemplate: {
Name: emailTemplateName
}
}
}
};
pinpoint.sendUsersMessages(params, function(err, data) {
if (err) {
console.log(err, err.stack); // an error occurred
callback(err, {"test": "Error Occoured"});
} else {
console.log(data); // successful response
callback(err, {"test": "Error Occoured"});
}
});
};

这是我得到的回复: Response

最佳答案

我也遇到了同样的问题。您可能拥有旧版本的 aws - sdk。

npm install aws-sdk

关于node.js - 使用 sendUsersMessages(javascript SDK)时,AWS Pinpoint 出现 TemplateConfiguration 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59217009/

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