diff --git a/AmazonConnectSalesforceIntegration.png b/AmazonConnectSalesforceIntegration.png index 9632384..da985e8 100644 Binary files a/AmazonConnectSalesforceIntegration.png and b/AmazonConnectSalesforceIntegration.png differ diff --git a/README.md b/README.md index 222325d..faf0aec 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ For more information, please see the [AppExchange listing](https://appexchange.s ![Screenshot](AmazonConnectSalesforceIntegration.png) +## CTI Adapter Versions Compatibility + +[Link to Compatibility Chart](https://amazon-connect.github.io/amazon-connect-salesforce-cti/docs/lightning/installation/04-salesforce-lambdas-manual-setup#compatibility-table) + ## Deploying from Github To deploy from the Github package, you need to use the [AWS SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html). First we will need to zip up the lambda code, you can do this by running `zip -r -j sam-app/lambda_functions/sam-app-deployment-artifact.zip sam-app/lambda_functions` from the root folder of this repository. @@ -39,4 +43,3 @@ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more inform ## License This project is licensed under the Apache-2.0 License. - diff --git a/sam-app/lambda_functions/salesforce.py b/sam-app/lambda_functions/salesforce.py index 631bc1b..93f3ad3 100755 --- a/sam-app/lambda_functions/salesforce.py +++ b/sam-app/lambda_functions/salesforce.py @@ -257,4 +257,4 @@ def __check_resp__(resp): raise Exception(msg) class InvalidAuthTokenException(Exception): - pass \ No newline at end of file + pass diff --git a/sam-app/lambda_functions/sfComprehendUtil.py b/sam-app/lambda_functions/sfComprehendUtil.py index ee09651..d509cfe 100644 --- a/sam-app/lambda_functions/sfComprehendUtil.py +++ b/sam-app/lambda_functions/sfComprehendUtil.py @@ -181,6 +181,9 @@ def processTranscript(iItems): for alternative in iTranscript['alternatives']: if(float(alternative['confidence']) > maxAlternativeConfidenceScore): selectedAlternative = alternative['content'] + maxAlternativeConfidenceScore = alternative['confidence'] + if(len(selectedAlternative) == 0): # if the selected alternative to be added is empty then it must not be added. this will prevent lastItem to ever be empty + continue transcript['content'] = selectedAlternative if(len(transcripts)>0): lastItem = transcripts[len(transcripts)-1] diff --git a/sam-app/lambda_functions/sfExecuteTranscriptionStateMachine.py b/sam-app/lambda_functions/sfExecuteTranscriptionStateMachine.py index 7d799e9..8598a8a 100644 --- a/sam-app/lambda_functions/sfExecuteTranscriptionStateMachine.py +++ b/sam-app/lambda_functions/sfExecuteTranscriptionStateMachine.py @@ -165,6 +165,9 @@ def createACContactChannelAnalyticsSalesforceObject(contactId, customerEndpoint, sfRequest['Details']['Parameters'][pnamespace + 'ContactId__c'] = contactId sfRequest['Details']['Parameters'][pnamespace + 'RecordingPath__c'] = recordingPath sfRequest['Details']['Parameters'][pnamespace + 'CustomerEndpointAddress__c'] = customerEndpoint['Address'] + sfRequest['Details']['Parameters'][pnamespace + 'InstanceId__c'] = os.environ['AMAZON_CONNECT_INSTANCE_ID'] + sfRequest['Details']['Parameters'][pnamespace + 'Region__c'] = os.environ['AMAZON_CONNECT_INSTANCE_REGION'] + ACContactChannelAnalyticsId = invokeSfAPI(sfRequest)['Id'] logger.info('SF Object Created, with ID: %s' % ACContactChannelAnalyticsId) diff --git a/sam-app/lambda_functions/sfIntervalAgent.py b/sam-app/lambda_functions/sfIntervalAgent.py index 9931db6..2845d27 100644 --- a/sam-app/lambda_functions/sfIntervalAgent.py +++ b/sam-app/lambda_functions/sfIntervalAgent.py @@ -23,7 +23,7 @@ limitations under the License. """ -import json, csv, os +import json, csv, os, re import boto3 import urllib.parse from salesforce import Salesforce @@ -58,14 +58,9 @@ def lambda_handler(event, context): for record in csv.DictReader(data.split("\n")): logger.info("sfIntervalAgent record: %s" % record) - #sf.create(pnamespace + "AC_AgentPerformance__c", prepare_agent_record(record, event_record['eventTime'])) agent_record = prepare_agent_record(record, event_record['eventTime']) - #logger.info("AC_Object_Name__c: %s" % agent_record[pnamespace + 'AC_Object_Name__c']) - #logger.info("StartInterval__c: %s" % agent_record[pnamespace + 'StartInterval__c']) ac_record_id = "%s%s" % (agent_record[pnamespace + 'AC_Object_Name__c'], agent_record[pnamespace + 'StartInterval__c']) - #logger.info("sfIntervalAgent ac_record_id: %s" % ac_record_id) - #logger.info("sfIntervalAgent record: %s" % agent_record) - #logger.info("sfIntervalAgent record: %s" % agent_record) + sf.update_by_external(pnamespace + "AC_AgentPerformance__c", pnamespace + 'AC_Record_Id__c',ac_record_id, agent_record) logger.info("done") @@ -84,8 +79,10 @@ def label_parser(key): if key.lower() == "agent": return pnamespace + "AC_Object_Name__c" + + key = re.sub(r'[-\s]+', '_', key) - return pnamespace + "%s__c" % key.replace(" ", "_") + return pnamespace + "%s__c" % key def value_parser(value): return value.replace("%", "") if len(value) > 0 else None diff --git a/sam-app/lambda_functions/sfIntervalQueue.py b/sam-app/lambda_functions/sfIntervalQueue.py index beda6fa..2b3f129 100644 --- a/sam-app/lambda_functions/sfIntervalQueue.py +++ b/sam-app/lambda_functions/sfIntervalQueue.py @@ -23,7 +23,7 @@ limitations under the License. """ -import json, csv, urllib.parse, logging, os +import json, csv, urllib.parse, logging, os, re import boto3 from salesforce import Salesforce @@ -53,7 +53,8 @@ def lambda_handler(event, context): for record in csv.DictReader(data.split("\n")): queue_record = prepare_queue_record(record, event_record['eventTime']) - ac_record_id = "%s%s" % (queue_record[pnamespace + 'AC_Object_Name__c'], queue_record[pnamespace + 'StartInterval__c']) + queue_name = re.sub(r'[-\s\W]+', '', queue_record[pnamespace + 'AC_Object_Name__c']) + ac_record_id = "%s%s" % (queue_name, queue_record[pnamespace + 'StartInterval__c']) #logger.info("sfIntervalAgent ac_record_id: %s" % ac_record_id) #logger.info("sfIntervalAgent record: %s" % queue_record) # logger.info("sfIntervalAgent record: %s" % agent_record) @@ -75,8 +76,10 @@ def label_parser(key): if key.lower() == "queue": return pnamespace + "AC_Object_Name__c" + + key = re.sub(r'[-\s]+', '_', key) - return pnamespace + "%s__c" % key.replace(" ", "_") + return pnamespace + "%s__c" % key def value_parser(value): - return value.replace("%", "") if len(value) > 0 else None \ No newline at end of file + return value.replace("%", "") if len(value) > 0 else None diff --git a/sam-app/lambda_functions/template.yaml b/sam-app/lambda_functions/template.yaml index a31c56f..664da55 100644 --- a/sam-app/lambda_functions/template.yaml +++ b/sam-app/lambda_functions/template.yaml @@ -1337,6 +1337,10 @@ Resources: Fn::GetAtt: sfInvokeAPI.Arn SF_ADAPTER_NAMESPACE: Ref: SalesforceAdapterNamespace + AMAZON_CONNECT_INSTANCE_ID: + Ref: AmazonConnectInstanceId + AMAZON_CONNECT_INSTANCE_REGION: + Ref: AWS::Region LOGGING_LEVEL: Ref: LambdaLoggingLevel @@ -1616,5 +1620,3 @@ Resources: - Effect: Allow Action: states:StartExecution Resource: !Ref sfRealTimeQueueMetricsLoopJobStateMachine - -