1

I'm trying to send messages with Pinpoint from a Lambda function in javascript. I'm following this documentation

When I try to use templates I get an Unexpected key error for the value 'TemplateConfiguration' This is my lambda function:

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"});
        }
    });
};

This is the response that i get: Response

berunda
  • 11
  • 1

1 Answers1

0

I phased the same problem. You probably have and old version of the aws - sdk.

npm install aws-sdk
bembas
  • 762
  • 8
  • 20