Setup - Backup via E-Mail

<< Click to Display Table of Contents >>

Navigation:  Installation > Backup and archive Audio File / Setup > Archive via E-Mail >

Setup - Backup via E-Mail

 

1.Phone system sends an email to the Amazon SES email address with call recording file as attachment.

email-with-attachment

2.Configure Amazon SES to send a copy of incoming email in raw format to Amazon S3. Amazon SES incoming receipt rules should send the email to S3 bucket using S3 action.

Amazon  Help Links -

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email.html

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-setting-up.html

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-receipt-rules.html

https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-s3.html

 

Steps to create a new rule for the active rule set that copies email sent to a specific email address into a specific S3 bucket

1.Select the option ‘Create Rule’ under Amazon SES — Rule Sets — View Active Rule Set.

2.Add a recipient to personalize the rule. In this case, added recipient as noreply@alaas.de.

3.Add an action for ‘S3’ by choosing a destination S3 bucket where the raw email message format should be copied to.

4.Select an existing S3 bucket or create a bucket from the dropdown option. In this specific case, created a S3 bucket ‘mirage-ses-service’. Bucket names are globally unique and hence choose a bucket name of your choice. Optionally select an object key prefix. Else continue to next step

5.Provide a rule name and create the rule

incoming-rule-set

 

 

Amazon S3 bucket which receives the incoming emails to the Amazon Email address

incoming-email-s3-bucket

 

 

We can apply life cycle rule on S3 bucket to delete emails after processing.

delete-emails-rule

 

3.Configure S3 event notifications to invoke AWS Lambda (when email in raw format is added to S3) and extract the email attachment to another S3 bucket. Trigger lambda function on S3 bucket which should read the email content and get the call recording attachment and save it into call recording S3 bucket.

 

s3-trigger-extract-attachment

 

 

4.Create AWS Lambda function in python to extract email attachment from raw email message.

       Below are the steps to create an AWS lambda function in python to extract email attachment:

1.        Navigate to Lambda in AWS Console

2. Create a function by providing a function name, runtime and default execution role. In this case, select function name as ‘extract-email-attachment’ and runtime as ‘Python 3.8’. For default execution role, select a pre-created role that includes permissions for Lambda and S3 (This can be created prior to this step via AWS  IAM)

3.Copy the code mentioned below

Python lambda file download - https://www.dropbox.com/s/uee18k879138mmc/lambda_function.py?dl=0

 Change the bucket name in the lambda to the S3 bucket name where attachments will be saved after processing.

lambda-extraxt-attachment

 

Amazon S3 bucket for saving the attachments

s3-bucket-attachment

 

 

Extracted files from the emails

s3-attachment-files

 

5.Audio Link and Archive Service for Salesforce can then read the audio recording from the  S3 bucket and play in Salesforce.