Hello,
I am using the AWS JavaScript SDK to create endpoints. I have an AWS Lambda which has logic that creates an endpoints. I call the Lambda via GraphQL when a user is created so that the user gets an endpoint on creation.
I setup the all users to have an active endpoint but literaly after a few minutes of creation every user's endpoint becomes INACTIVE. Why is that the case?
Here is the code I use to create the endpoint:
const { Pinpoint } = require("aws-sdk");
const AWS = require("aws-sdk")
const pinpoint = new AWS.Pinpoint();
exports.handler = async (event) => {
const marketing = event.arguments.marketing;
const typeAction = event.arguments.typeAction;
const endpointAddress = event.arguments.address;
const projectId = projectID;
const valueAction = event.arguments.valueAction;
const endpointID = generateEndpointID(20);
const params = {
ApplicationId: projectId, /* required */
EndpointId: endpointID, /* required */
EndpointRequest: { /* required */
Address: endpointAddress,
Attributes: {
typeAction : [typeAction],
valueAction : [valueAction],
marketing : [marketing],
},
ChannelType: "EMAIL",
EndpointStatus: 'ACTIVE',
OptOut: 'NONE',
User: {
UserAttributes: {
//
},
UserId: endpointAddress
}
}
};
const pinpointRes = await pinpoint.updateEndpoint(params).promise().catch(er=> {console.log(er)});
return endpointID;
};