Skip to content

Commit

Permalink
v5.22 (#58)
Browse files Browse the repository at this point in the history
* Merges in lambda changes for v5.22

* Updates README to include link to compatibility chart
  • Loading branch information
sderacy authored Feb 2, 2024
1 parent adfff25 commit 27f8467
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 16 deletions.
Binary file modified AmazonConnectSalesforceIntegration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

2 changes: 1 addition & 1 deletion sam-app/lambda_functions/salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@ def __check_resp__(resp):
raise Exception(msg)

class InvalidAuthTokenException(Exception):
pass
pass
3 changes: 3 additions & 0 deletions sam-app/lambda_functions/sfComprehendUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 5 additions & 8 deletions sam-app/lambda_functions/sfIntervalAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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
11 changes: 7 additions & 4 deletions sam-app/lambda_functions/sfIntervalQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
return value.replace("%", "") if len(value) > 0 else None
6 changes: 4 additions & 2 deletions sam-app/lambda_functions/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1616,5 +1620,3 @@ Resources:
- Effect: Allow
Action: states:StartExecution
Resource: !Ref sfRealTimeQueueMetricsLoopJobStateMachine


0 comments on commit 27f8467

Please sign in to comment.