in functions/kvs_trigger.js [83:116]
function updateDynamo(event){
let customerPhoneNumber = event.Details.ContactData.CustomerEndpoint.Address;
let contactId = event.Details.ContactData.ContactId;
//Sets the timezone environment variable for the Lambda function to east coast. You can change this to your preferred timezone, or remove this line to use UTC
process.env.TZ = "America/New_York";
var tableName = process.env.table_name;
var currentTimeStamp = new Date().toString();
var currentDate = new Date().toLocaleDateString();
//set up the database query to be used to update the customer information record in DynamoDB
var paramsUpdate = {
TableName: tableName,
Key: {
"contactId": contactId
},
ExpressionAttributeValues: {
":var1": customerPhoneNumber,
":var2": currentDate,
":var3": currentTimeStamp
},
UpdateExpression: "SET customerPhoneNumber = :var1, callDate = :var2, callTimestamp = :var3"
};
//update the customer record in the database with the new call information using the paramsUpdate query we setup above:
docClient.update(paramsUpdate, function (err, data) {
if (err) {
console.log("Unable to update item. Error: ", JSON.stringify(err, null, 2));
} else console.log("Updated item succeeded!: ", JSON.stringify(data, null, 2));
});
}