in assets/ComprehendTask.py [0:0]
def lambda_handler(event, context):
contactID = event['Records'][0]['dynamodb']['NewImage']['contactId']['S'];
eventName=event['Records'][0]['eventName'];
#create_presigned_url('ac-kinesis-video-stream-transcription','recordings/01c1ae2a-b945-42e1-b966-c661222f993e_2020-12-18T19:26:29.032+0000_AUDIO_FROM_CUSTOMER.wav')
#get_Entities(event['Records'][0]['dynamodb']['NewImage']['contactTranscriptFromCustomer']['S'])
#if eventName == 'INSERT':
#put_contactID(contactID, "false")
if eventName == 'MODIFY':
print('ComprehendMedicalTask() event is: ', event)
new_image = event['Records'][0]['dynamodb']['NewImage']
old_image = event['Records'][0]['dynamodb']['OldImage']
#trigger lambda only once, after combined audio file is created
#if ( 'combinedAudio' in new_image and 'combinedAudio' not in old_image):
if ( ('mergeStatus' in new_image) and (new_image['mergeStatus']['S'] == 'Complete') ):
if ( 'audioFromCustomer' in new_image and 'contactTranscriptFromCustomer' in new_image ):
contactID = new_image['contactId']['S'];
responseFromDB = get_isTaskCreated(contactID)
if responseFromDB['isTaskCreated'] == 'false':
urlToRecording = new_image['audioFromCustomer']['S'];
contactTranscriptFromCustomer = new_image['contactTranscriptFromCustomer']['S'];
#ANI = new_image['customerPhoneNumber']['S']
#employID = new_image['']
callStartTaskLambda(
create_presigned_url('ac-kinesis-video-stream-transcription',split_at(urlToRecording,'/',3)[1]),
contactTranscriptFromCustomer,
get_Entities(contactTranscriptFromCustomer),
get_KeyPhrase(contactTranscriptFromCustomer),
responseFromDB['ANI'],
responseFromDB['EmployeeID'])
update_contactID(contactID,'true')
else:
print('ERROR: ComprehendMedicalTask() triggered on MODIFY with missing attributes...DO NOTHING')
else:
print('ComprehendMedicalTask() triggered on MODIFY but Contact Summary is NOT done yet...DO NOTHING')