in functions/process_contact.js [124:167]
function getTranscript(contactId, tableName) {
return new Promise(function (resolve, reject) {
var docClient = new aws.DynamoDB.DocumentClient();
//set up the database query to be used to lookup customer information from DynamoDB
var paramsQuery = {
TableName: tableName,
KeyConditionExpression: "ContactId = :varContactId",
ExpressionAttributeValues: {
":varContactId": contactId
}
};
console.log("querying ddb with: " + JSON.stringify(paramsQuery));
//use the lookup query (paramsQuery) we set up to lookup the contact transcript segments from DynamoDB
docClient.query(paramsQuery, (err, dbResults) => {
//check to make sure the query executed correctly, if so continue, if not error out the lambda function
if (err) {
console.log(err);
reject();
}
//if no error occured, proceed to process the results that came back from DynamoDB
else {
//log the results from the DynamoDB query
var transcript = "";
var results = dbResults.Items;
for (var i = 0; i <= results.length - 1; i++) {
transcript += results[i].Transcript + " ";
}
if (transcript) {
transcript = transcript;
} else transcript = "Transcript not available for this call";
console.log("table (" + tableName +") has the transcript: " + transcript);
resolve(transcript);
}
});
});
}