diff --git a/sam-app/lambda_functions/sfContactTraceRecord.py b/sam-app/lambda_functions/sfContactTraceRecord.py index 2cc9234..a6fbd6c 100644 --- a/sam-app/lambda_functions/sfContactTraceRecord.py +++ b/sam-app/lambda_functions/sfContactTraceRecord.py @@ -92,8 +92,6 @@ def create_ctr_record(ctr): # Customer Data if ctr['CustomerEndpoint']: sf_request[objectnamespace + 'CustomerEndpointAddress__c'] = ctr['CustomerEndpoint']['Address'] - if ctr['ContactDetails']: - sf_request[objectnamespace + 'ContactDetails__c'] = json.dumps(ctr['ContactDetails']) sf_request[objectnamespace + 'InitiationTimestamp__c'] = ctr['InitiationTimestamp'] sf_request[objectnamespace + 'InitialContactId__c'] = ctr['InitialContactId'] @@ -103,7 +101,6 @@ def create_ctr_record(ctr): sf_request[objectnamespace + 'LastUpdateTimestamp__c'] = ctr['LastUpdateTimestamp'] sf_request[objectnamespace + 'NextContactId__c'] = ctr['NextContactId'] sf_request[objectnamespace + 'PreviousContactId__c'] = ctr['PreviousContactId'] - sf_request[objectnamespace + 'DisconnectReason__c'] = ctr['DisconnectReason'] sf_request[objectnamespace + 'DisconnectTimestamp__c'] = ctr['DisconnectTimestamp'] # Queue @@ -120,10 +117,6 @@ def create_ctr_record(ctr): sf_request[objectnamespace + 'RecordingStatus__c'] = ctr['Recording']['Status'] sf_request[objectnamespace + 'RecordingDeletionReason__c'] = ctr['Recording']['DeletionReason'] - # Reference - if ctr['References']: - sf_request[objectnamespace + 'References__c'] = json.dumps(ctr['References']) - # System End Data if ctr['SystemEndpoint']: sf_request[objectnamespace + 'SystemEndpointAddress__c'] = ctr['SystemEndpoint']['Address'] diff --git a/sam-app/lambda_functions/sfRealTimeQueueMetrics.py b/sam-app/lambda_functions/sfRealTimeQueueMetrics.py index 526d0e9..3ba9886 100644 --- a/sam-app/lambda_functions/sfRealTimeQueueMetrics.py +++ b/sam-app/lambda_functions/sfRealTimeQueueMetrics.py @@ -100,7 +100,7 @@ def ac_queue_metrics(queue_id_name_dict,queue_ids, instance_id): current_metrics = [ { 'Name': 'AGENTS_ONLINE', 'Unit': 'COUNT' }, { 'Name': 'AGENTS_AVAILABLE', 'Unit': 'COUNT' }, - { 'Name': 'AGENTS_ON_CALL', 'Unit': 'COUNT' }, + { 'Name': 'AGENTS_ON_CONTACT', 'Unit': 'COUNT' }, { 'Name': 'AGENTS_STAFFED', 'Unit': 'COUNT' }, { 'Name': 'AGENTS_AFTER_CONTACT_WORK', 'Unit': 'COUNT' }, { 'Name': 'AGENTS_NON_PRODUCTIVE', 'Unit': 'COUNT' }, @@ -114,7 +114,7 @@ def ac_queue_metrics(queue_id_name_dict,queue_ids, instance_id): if next_token == 'NoToken': logger.info("Call QueueMetric : without no token") currentMetrics_data = connect.get_current_metric_data(InstanceId = instance_id, - Filters = {'Channels': ['VOICE'],'Queues': queue_ids}, + Filters = {'Channels': ['VOICE', 'CHAT', 'TASK'], 'Queues': queue_ids}, Groupings = ['QUEUE'], CurrentMetrics = current_metrics, MaxResults = int(queuemetics_max_result) @@ -122,7 +122,7 @@ def ac_queue_metrics(queue_id_name_dict,queue_ids, instance_id): else: logger.info("Call QueueMetric : with token") currentMetrics_data = connect.get_current_metric_data(InstanceId = instance_id, - Filters = {'Channels': ['VOICE'],'Queues': queue_ids}, + Filters = {'Channels': ['VOICE', 'CHAT', 'TASK'], 'Queues': queue_ids}, Groupings = ['QUEUE'], CurrentMetrics = current_metrics, MaxResults = int(queuemetics_max_result), @@ -183,7 +183,7 @@ def ac_queue_metrics(queue_id_name_dict,queue_ids, instance_id): elif metric_data['Name'] == 'AGENTS_AVAILABLE' and 'Value' in metrics_data.keys() : agent_available = int(metrics_data['Value']) queue_metics_data_dict['agent_available'] = agent_available - elif metric_data['Name'] == 'AGENTS_ON_CALL' and 'Value' in metrics_data.keys() : + elif metric_data['Name'] == 'AGENTS_ON_CONTACT' and 'Value' in metrics_data.keys() : agent_on_call = int(metrics_data['Value']) queue_metics_data_dict['agent_on_call'] = agent_on_call elif metric_data['Name'] == 'AGENTS_STAFFED' and 'Value' in metrics_data.keys() : @@ -226,7 +226,7 @@ def prepare_record(queue_id_name_dict,queue_metric_data): record['Name'] = queue_id_name_dict[queue_metric_data['queue_id']] if 'queue_id' in queue_metric_data.keys(): - if 'Queue_ARN__c' in queue_metric_data.keys(): + if 'queue_arn' in queue_metric_data.keys(): record[objectnamespace + 'Queue_ARN__c'] = queue_metric_data['queue_arn'] else: record[objectnamespace + 'Queue_ARN__c'] = '' diff --git a/sam-app/lambda_functions/template.yaml b/sam-app/lambda_functions/template.yaml index 34f6db8..2e5167b 100644 --- a/sam-app/lambda_functions/template.yaml +++ b/sam-app/lambda_functions/template.yaml @@ -38,14 +38,16 @@ Parameters: AllowedPattern: (^$|^https(.*)) Type: String SalesforceUsername: - Default: Salesforce API Username - Description: The username of a valid Salesforce API account for your environment. + Default: apiuser@.com + Description: The username of a valid Salesforce API account for your environment. Salesforce usernames are in the form of an email address. For example, user@domain.com Type: String + AllowedPattern: ^.+@.+\..+$ SalesforceVersion: Default: v42.0 - Description: To find the Salesforce Edition and API Version please visit https://help.salesforce.com/articleView?id=000199268&type=1 + Description: To find the Salesforce Edition and API Version please visit https://help.salesforce.com/articleView?id=000199268&type=1. The pattern for this field is vXX.X Type: String + AllowedPattern: ^v[0-9]+\.[0-9]+$ ConnectReportingS3BucketName: Default: '' Description: This is the S3 bucket where Amazon Connect stores scheduled reports. Please refer to http://docs.aws.amazon.com/connect/latest/adminguide/amazon-connect-instance.html#datastorage @@ -278,8 +280,8 @@ Resources: PolicyDocument: Statement: - Action: - - kms:decrypt - - kms:generatedatakey + - kms:Decrypt + - kms:GenerateDataKey Effect: Allow Resource: !Ref SalesforceCredentialsKMSKeyARN Version: '2012-10-17' @@ -347,6 +349,7 @@ Resources: - sts:AssumeRole ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - Fn::If: - AmazonConnectInstanceIdHasValue @@ -421,7 +424,7 @@ Resources: - iam:CreateServiceLinkedRole Effect: Allow Resource: - Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/aws-service-role/connect.amazonaws.com/* + Fn::Sub: arn:aws:iam::${AWS::AccountId}:role/aws-service-role/connect.amazonaws.com* Version: '2012-10-17' PolicyName: sfExecuteAWSServiceServiceLinkedRolePolicy - Fn::If: @@ -582,6 +585,7 @@ Resources: Path: / ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - PolicyDocument: Statement: @@ -607,6 +611,7 @@ Resources: Path: / ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - PolicyDocument: Statement: @@ -631,6 +636,7 @@ Resources: Path: / ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - PolicyDocument: Statement: @@ -681,6 +687,7 @@ Resources: Path: / ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - PolicyDocument: Statement: @@ -772,6 +779,7 @@ Resources: Path: / ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - Fn::If: - CTREventSourceMappingCondition @@ -813,6 +821,7 @@ Resources: Path: / ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - Fn::If: - sfProcessTranscriptionResultS3PolicyCondition @@ -860,6 +869,7 @@ Resources: Path: / ManagedPolicyArns: - !Ref CloudWatchManagedPolicy + - !If [PrivateVpcEnabledCondition, !Ref VpcManagedPolicy, !Ref AWS::NoValue] Policies: - Fn::If: - sfProcessContactLensResultS3PolicyCondition @@ -1039,7 +1049,10 @@ Resources: SALESFORCE_HOST: Ref: SalesforceHost SIG4_LAMBDA_ROLE_ARN: - Fn::GetAtt: sfSig4RequestToS3Role.Arn + Fn::If: + - PostcallRecordingImportEnabledCondition + - Fn::GetAtt: sfSig4RequestToS3Role.Arn + - !Ref AWS::NoValue sfContactTraceRecord: Type: AWS::Serverless::Function @@ -1179,6 +1192,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfRealTimeQueueMetricsLoopJob.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfRealTimeQueueMetricsLoopJobRole.Arn Layers: @@ -1196,6 +1215,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfGenerateAudioRecordingStreamingURL.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfLambdaBasicExec.Arn Layers: @@ -1242,6 +1267,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfGetTranscribeJobStatus.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfGetTranscribeJobStatusRole.Arn Layers: @@ -1256,6 +1287,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfSubmitTranscribeJob.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfSubmitTranscribeJobRole.Arn Layers: @@ -1270,6 +1307,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfExecuteTranscriptionStateMachine.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfExecuteTranscriptionStateMachineRole.Arn Layers: @@ -1297,6 +1340,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfCTRTrigger.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfCTRTriggerRole.Arn Layers: @@ -1333,6 +1382,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfProcessTranscriptionResult.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfProcessTranscriptionResultRole.Arn Layers: @@ -1351,6 +1406,12 @@ Resources: Type: AWS::Serverless::Function Properties: Handler: sfProcessContactLens.lambda_handler + VpcConfig: + !If + - PrivateVpcEnabledCondition + - SubnetIds: !Ref VpcSubnetList + SecurityGroupIds: !Ref VpcSecurityGroupList + - Ref: AWS::NoValue Role: Fn::GetAtt: sfProcessContactLensRole.Arn Timeout: 60