in assets/ComprehendTask.py [0:0]
def callStartTaskLambda(urlToRecording,contactTranscriptFromCustomer,entities, keyphrase, ANI, EmployeeID):
print('callStartTaskLambda() is called')
print('urlToRecording: {0}, contactTranscriptFromCustomer: {1}, entities: {2}, keyphrase: {3}, ANI: {4}, EmployeeID: {5}'.format(
urlToRecording, contactTranscriptFromCustomer, entities, keyphrase, ANI, EmployeeID))
client = boto3.client('lambda')
taskReferences = {
'urlToRecording': {
'Value': urlToRecording,
'Type': 'URL'
}
}
symptoms = ''
if len(entities) == 0:
#make sure we dont pass '' to Task, which would be bad parameter
symptoms = 'NONE'
else:
symptoms = ' '.join(entities)
"""
for entity in entities:
if symptoms == '':
symptoms = entity
else:
symptoms = symptoms + ', ' + entity
"""
keyphrases = ''
if len(keyphrase) == 0:
#make sure we dont pass '' to Task, which would be bad parameter
keyphrases = 'NONE'
else:
keyphrases = ' '.join(keyphrase)
"""
for phrase in keyphrase:
if (keyphrases == ''):
keyphrases = phrase
else:
keyphrases = keyphrases + ', ' + phrase
"""
taskAttributes = {
'SYMPTOM': symptoms,
'KEYPHRASE': keyphrases,
'ANI': ANI,
'EmployeeID': EmployeeID
}
taskName = 'Task for EmployeeID: {0} with ANI: {1}'.format(EmployeeID, ANI)
taskDescripton = contactTranscriptFromCustomer
print('taskName is: {}'.format(taskName))
print('taskAttributes is: {}'.format(taskAttributes))
print('taskReferences is: {}'.format(taskReferences))
print('taskDescripton is: {}'.format(taskDescripton))
connectClient = boto3.client('connect')
respBody = ''
try:
response = connectClient.start_task_contact(
InstanceId = os.environ['INSTANCE_ID'],
ContactFlowId = os.environ['CONTACT_FLOW_ID'],
#PreviousContactId = "some-previous-contact-id",
Attributes = taskAttributes,
Name = taskName,
References = taskReferences,
Description = taskDescripton
#ClientToken = event['clientToken']
)
print('start_task_contact() response is: ', response)
respBody = response['ContactId']
except Exception as e:
print('Exception on start_task_contact: ', e)
return {
'statusCode': 500,
'body': e
}
return {
'statusCode': 200,
'body': {'ContactId': respBody}
}