Skip to content

Commit

Permalink
Merge pull request amazon-connect#23 from amazon-connect/release-5.14
Browse files Browse the repository at this point in the history
Release 5.14
  • Loading branch information
yingdoli authored Jun 14, 2021
2 parents bee2ccc + 002ae74 commit bd5d1e9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions sam-app/lambda_functions/sfCTRTrigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def send_data(data_to_send):
event_to_send = event_template.copy()
event_to_send['record'] = data_to_send

if os.environ["POSTCALL_RECORDING_IMPORT_ENABLED"] == 'true' or os.environ["POSTCALL_TRANSCRIBE_ENABLED"] == 'true':
if os.environ["POSTCALL_RECORDING_IMPORT_ENABLED"].lower() == 'true' or os.environ["POSTCALL_TRANSCRIBE_ENABLED"].lower() == 'true':
logger.info('Invoke EXECUTE_TRANSCRIPTION_STATE_MACHINE_LAMBDA')
boto3.client('lambda').invoke(FunctionName=os.environ["EXECUTE_TRANSCRIPTION_STATE_MACHINE_LAMBDA"], InvocationType='Event', Payload=json.dumps(event_to_send))

if os.environ["POSTCALL_CTR_IMPORT_ENABLED"] == 'true':
if os.environ["POSTCALL_CTR_IMPORT_ENABLED"].lower() == 'true':
logger.info('Invoke EXECUTE_CTR_IMPORT_LAMBDA')
boto3.client('lambda').invoke(FunctionName=os.environ["EXECUTE_CTR_IMPORT_LAMBDA"], InvocationType='Event', Payload=json.dumps(event_to_send))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ def lambda_handler(event, context):
logger.info("Cloudfront credentials retrieved")

# construct url to audio recording
if "/connect/" or "/Analysis/" not in event['recordingPath']:
logger.error("Invalid s3 path for recording.")
recordingPath = event['recordingPath'].split("/", 1)[1] # need to remove bucket name, connect dir from path
recordingPath = event['recordingPath'].split("/connect/", 1)[1] # need to remove bucket name, connect dir from path
cloudfront_domain = get_arg(os.environ, 'CLOUDFRONT_DISTRIBUTION_DOMAIN_NAME')
url = 'https://' + cloudfront_domain + '/' + recordingPath
logger.info('Unsigned audio recording url: %s' % url)
Expand Down
9 changes: 7 additions & 2 deletions sam-app/lambda_functions/sfGetTranscribeJobStatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ def lambda_handler(event, context):
)
# BELOW IS THE CODE TO FIX SERIALIZATION ON DATETIME OBJECTS
if "CreationTime" in response["TranscriptionJob"]:
response["TranscriptionJob"]["CreationTime"] = str(response["TranscriptionJob"]["CreationTime"])
val = response["TranscriptionJob"]["CreationTime"]
response["TranscriptionJob"]["CreationTime"] = val.strftime("%Y-%m-%dT%H:%M:%S.%f%z") if isinstance(val, datetime.datetime) else str(val)
if "StartTime" in response["TranscriptionJob"]:
val = response["TranscriptionJob"]["StartTime"]
response["TranscriptionJob"]["StartTime"] = val.strftime("%Y-%m-%dT%H:%M:%S.%f%z") if isinstance(val, datetime.datetime) else str(val)
if "CompletionTime" in response["TranscriptionJob"]:
response["TranscriptionJob"]["CompletionTime"] = str(response["TranscriptionJob"]["CompletionTime"])
val = response["TranscriptionJob"]["CompletionTime"]
response["TranscriptionJob"]["CompletionTime"] = val.strftime("%Y-%m-%dT%H:%M:%S.%f%z") if isinstance(val, datetime.datetime) else str(val)
logger.info(response)
return response["TranscriptionJob"]
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion sam-app/lambda_functions/sfProcessContactLens.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

def lambda_handler(event, context):
# Check if Contact Lens is enabled at application level
if os.environ["CONTACT_LENS_IMPORT_ENABLED"] != 'true':
if os.environ["CONTACT_LENS_IMPORT_ENABLED"].lower() != 'true':
logger.warning('Contact Lens Import is disabled')
return {"Done": False}

Expand Down
9 changes: 7 additions & 2 deletions sam-app/lambda_functions/sfSubmitTranscribeJob.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ def lambda_handler(event, context):
)
# BELOW IS THE CODE TO FIX SERIALIZATION ON DATETIME OBJECTS
if "CreationTime" in response["TranscriptionJob"]:
response["TranscriptionJob"]["CreationTime"] = str(response["TranscriptionJob"]["CreationTime"])
val = response["TranscriptionJob"]["CreationTime"]
response["TranscriptionJob"]["CreationTime"] = val.strftime("%Y-%m-%dT%H:%M:%S.%f%z") if isinstance(val, datetime.datetime) else str(val)
if "StartTime" in response["TranscriptionJob"]:
val = response["TranscriptionJob"]["StartTime"]
response["TranscriptionJob"]["StartTime"] = val.strftime("%Y-%m-%dT%H:%M:%S.%f%z") if isinstance(val, datetime.datetime) else str(val)
if "CompletionTime" in response["TranscriptionJob"]:
response["TranscriptionJob"]["CompletionTime"] = str(response["TranscriptionJob"]["CompletionTime"])
val = response["TranscriptionJob"]["CompletionTime"]
response["TranscriptionJob"]["CompletionTime"] = val.strftime("%Y-%m-%dT%H:%M:%S.%f%z") if isinstance(val, datetime.datetime) else str(val)
return response["TranscriptionJob"]
except Exception as e:
raise(e)
17 changes: 9 additions & 8 deletions sam-app/lambda_functions/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ Parameters:


Conditions:
PostcallRecordingImportEnabledCondition: !Equals [!Ref PostcallRecordingImportEnabled, true ]
PostcallTranscribeEnabledCondition: !Equals [!Ref PostcallTranscribeEnabled, true]
PostcallCTRImportEnabledCondition: !Equals [!Ref PostcallCTRImportEnabled, true]
HistoricalReportingImportEnabledCondition: !Equals [!Ref HistoricalReportingImportEnabled, true]
RealtimeReportingImportEnabledCondition: !Equals [!Ref RealtimeReportingImportEnabled, true]
ContactLensImportEnabledCondition: !Equals [!Ref ContactLensImportEnabled, true]
PrivateVpcEnabledCondition: !Equals [!Ref PrivateVpcEnabled, true]
PostcallRecordingImportEnabledCondition: !Or [!Equals [!Ref PostcallRecordingImportEnabled, true ], !Equals [!Ref PostcallRecordingImportEnabled, 'True' ]]
PostcallTranscribeEnabledCondition: !Or [!Equals [!Ref PostcallTranscribeEnabled, true], !Equals [!Ref PostcallTranscribeEnabled, 'True']]
PostcallCTRImportEnabledCondition: !Or [!Equals [!Ref PostcallCTRImportEnabled, true], !Equals [!Ref PostcallCTRImportEnabled, 'True']]
HistoricalReportingImportEnabledCondition: !Or [!Equals [!Ref HistoricalReportingImportEnabled, true], !Equals [!Ref HistoricalReportingImportEnabled, 'True']]
RealtimeReportingImportEnabledCondition: !Or [!Equals [!Ref RealtimeReportingImportEnabled, true], !Equals [!Ref RealtimeReportingImportEnabled, 'True']]
ContactLensImportEnabledCondition: !Or [!Equals [!Ref ContactLensImportEnabled, true], !Equals [!Ref ContactLensImportEnabled, 'True']]
PrivateVpcEnabledCondition: !Or [!Equals [!Ref PrivateVpcEnabled, true], !Equals [!Ref PrivateVpcEnabled, 'True']]

CTREventSourceMappingCondition:
!Or
Expand Down Expand Up @@ -973,7 +973,8 @@ Resources:
OriginCustomHeaders:
- HeaderName: Access-Control-Allow-Origin
HeaderValue: !Ref SalesforceHost

OriginPath: /connect

sfGetTranscribeJobStatus:
Type: AWS::Serverless::Function
Properties:
Expand Down

0 comments on commit bd5d1e9

Please sign in to comment.