Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v5.19.1 #56

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*-perl-*-

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this file


package.AmazonConnectSalesforceLambda = {
interfaces = (1.0);

deploy = {
generic = true;
};

build-environment = {
chroot = basic;
network-access = blocked;
};

# Use NoOpBuild. See https://w.amazon.com/index.php/BrazilBuildSystem/NoOpBuild
build-system = custom-build;
build-tools = {
1.0 = {
BrazilPath = 1.1;
BrazilPython = 3.0;
};
};

# Use runtime-dependencies for when you want to bring in additional
# packages when deploying.
# Use dependencies instead if you intend for these dependencies to
# be exported to other packages that build against you.
dependencies = {
1.0 = {
Boto3 = 1.x;
BotoCore = 1.x;
Python-chardet = 3.0.x;
Python-dateutil = 2.x;
Python-docutils = 0.x;
Python-idna = 2.x;
Python-jmespath = 0.9.x;
Python-phonenumbers = 8.x;
Requests = 2.x.x;
Six = 1.x.x;
};
};

runtime-dependencies = {
1.0 = {
};
};

};
42 changes: 42 additions & 0 deletions build-tools/bin/custom-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this file

set -x # echo commands executed
set -e # fail script on any individual command failing

target=${1:-"release"}
echo "Target is $target"

if [ "$target" == "clean" ]
then
rm -rf build/*
elif [ "$target" == "deploy" ]
then
if [ ! -f samconfig.toml ];
then
sam deploy --guided --template-file build/template.yaml
mv build/samconfig.toml ./samconfig.toml
else
sam deploy --template-file build/template.yaml --config-file ../samconfig.toml;
fi
elif [ "$target" == "release" ]
then
rm -rf build/*

lib_farm="$(brazil-path build.libfarm)/lib"

cp sam-app/lambda_functions/template.yaml build/
cp LICENSE build/
cp README.md build/

cp -r sam-app/lambda_functions/ build/sam-app-deployment-artifact
mkdir build/sam-app-deployment-artifact/lib
(cd build/ && zip -r -j sam-app-deployment-artifact.zip sam-app-deployment-artifact/)
rm -rf build/sam-app-deployment-artifact/

mkdir -p build/python/lib/
cp -r $lib_farm/python3.10 build/python/lib
(cd build/ && zip -r lambda_layers python)
rm -rf build/python/
else
printf "$target is not a valid argument"
exit 1
fi
36 changes: 36 additions & 0 deletions sam-app/lambda_functions/sfInvokeAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ def lambda_handler(event, context):
resp = search(sf=sf, **event['Details']['Parameters'])
elif (sf_operation == "searchOne"):
resp = searchOne(sf=sf, **event['Details']['Parameters'])
elif (sf_operation == "searchSOSL"):
resp = searchSOSL(sf=sf, **event['Details']['Parameters'])
elif (sf_operation == "searchOneSOSL"):
resp = searchOneSOSL(sf=sf, **event['Details']['Parameters'])
else:
msg = "sf_operation unknown"
logger.error(msg)
Expand Down Expand Up @@ -268,6 +272,38 @@ def searchOne(sf, q, sf_fields, sf_object, where="", **kwargs):
result['sf_count'] = count
return result

def searchSOSL(sf, query, **kwargs):
for key, value in kwargs.items():
logger.info("Replacing [%s] with [%s] in [%s]" % (key, value, query))
query = query.replace(key, value)

records = sf.search(query=query)
count = len(records)
result = {}

if count > 0:
recordArray = {}
for record in records:
recordArray[str(records.index(record))] = flatten_json(record)

result['sf_records'] = recordArray
else:
result['sf_records'] = {}

result['sf_count'] = count
return flatten_json(result, '_')

def searchOneSOSL(sf, query, **kwargs):
for key, value in kwargs.items():
logger.info("Replacing [%s] with [%s] in [%s]" % (key, value, query))
query = query.replace(key, value)

records = sf.query(query=query)
count = len(records)
result = flatten_json(records[0]) if count == 1 else {}
result['sf_count'] = count
return result

def flatten_json(nested_json, separator = '.'):
out = {}

Expand Down
16 changes: 10 additions & 6 deletions sam-app/lambda_functions/sfProcessContactLens.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ def lambda_handler(event, context):
return {"Done": False}

logger.info('Getting lock file metadata: %s ' % contactId)
oMetadata = getS3FileMetadata(os.environ['TRANSCRIPTS_DESTINATION'], contactId)

mACContactChannelAnalyticsId = None
if 'ACContactChannelAnalyticsId'.lower() in oMetadata:
mACContactChannelAnalyticsId = oMetadata['ACContactChannelAnalyticsId'.lower()]
oMetadata = None
transcribeBucketExists = os.environ['TRANSCRIPTS_DESTINATION'] != ''
if transcribeBucketExists:
oMetadata = getS3FileMetadata(os.environ['TRANSCRIPTS_DESTINATION'], contactId)

if 'ACContactChannelAnalyticsId'.lower() in oMetadata:
mACContactChannelAnalyticsId = oMetadata['ACContactChannelAnalyticsId'.lower()]

logger.info('Processing ContactLens transcript')
participants = contactLensObj['Participants']
Expand All @@ -85,8 +88,9 @@ def lambda_handler(event, context):

createSalesforceObject(contactId, contactLensTranscripts, contactLensConversationCharacteristics, mACContactChannelAnalyticsId)

logger.info('Updating s3 metadata')
updateLock(os.environ['TRANSCRIPTS_DESTINATION'], contactId, oMetadata)
if transcribeBucketExists:
logger.info('Updating s3 metadata')
updateLock(os.environ['TRANSCRIPTS_DESTINATION'], contactId, oMetadata)

logger.info('Done')
return {"Done": True}
Expand Down
10 changes: 7 additions & 3 deletions sam-app/lambda_functions/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Parameters:
Type: Number
Default: 100
Description: Maximum retry attempts on failure for lambdas triggered by Kinesis Events
CTREventSourceMappingBatchSize:
Type: Number
Default: 30
Description: Batch size for lambdas triggered by Kinesis Events
SalesforceAdapterNamespace:
Default: 'amazonconnect'
Description: This is the namespace for CTI Adapter managed package. The default value is [amazonconnect]. If a non-managed package is used, leave this field blank.
Expand Down Expand Up @@ -232,7 +236,7 @@ Conditions:
Globals:
Function:
Timeout: 6
Runtime: python3.7
Runtime: python3.10
CodeUri: ./sam-app-deployment-artifact.zip
Ilapides marked this conversation as resolved.
Show resolved Hide resolved

Resources:
Expand All @@ -243,7 +247,7 @@ Resources:
Description: Salesforce Lambda function external dependencies
ContentUri: ./lambda_layers.zip
CompatibleRuntimes:
- python3.7
- python3.10

invokeSfExecuteAWSServicePolicy:
Type: AWS::IAM::ManagedPolicy
Expand Down Expand Up @@ -1375,7 +1379,7 @@ Resources:
FunctionName:
Fn::GetAtt: sfCTRTrigger.Arn
StartingPosition: "LATEST"
BatchSize: 100
BatchSize: !Ref CTREventSourceMappingBatchSize
martin-greenberg marked this conversation as resolved.
Show resolved Hide resolved
MaximumRetryAttempts: !Ref CTREventSourceMappingMaximumRetryAttempts

sfProcessTranscriptionResult:
Expand Down