Autoressbondor AI: Smart method of managing your inbox
With work and a private life that mixes more than ever, the management of the overwhelming excessive incoming box can be. But what if the responses to you can, do you just need to review you? Learn Autoressbonder AI: Email without a server on AWS who uses artificial intelligence to simplify the connection. This article will dismantle how it works and how it can make e -mails processing easier.
What is Autoressbonde AI?
Autoressbonder AI is a smart addition of Gmail that can help you manage emails and prevent excess pregnancy in the inbox. He wipes unreasonable emails, discovers feelings, drafts of drafts for those who need to respond, and provide them for your review. Once the drafts are ready, they teach you via email or SMS, which makes you updated. It is based on a safe and cost -effective system, it is ideal for busy professionals, customer service teams, or anyone who wants to stay responding to the least problem.
Why automatic stress from artificial intelligence?
- It enhances productivity – Automation of responses to unreasonable email messages, saving time and effort.
- Improving time management Artificial intelligence is used to determine the priorities and generate the responses of the context.
- Security guarantees – It protects the accreditation data with the AWS Secrets Director.
- It improves communication Vocational responses professional letter, specially designed for each recipient.
Autoresbonder AI is useful for business professionals, executives, sales teams and customer service departments because it brings AI’s automation power to the Innicated Postal Management efforts.
Step Step Directory to develop and publish Autorsboster AI
#Step 1: Gmail Gmail Oauth data from Google Console
To access the Gmail via API, you need the OATH credit data from Google Cloud Console.
-
Create Google Cloud
-
Open Google Cloud Console -> Select a new project -> You can call it GmailorePly or anything you choose -> Click Create.
-
-
Empowering Gmail API
-
Go to applications and services programming facades.
-
Enable applications and services programming facades, search for and enable Gmail API.
-
-
Create OATH credentials
-
Go to applications and services programming facades -> Accreditation data -> Create accreditation data -> OATH customer identifier.
-
Choose the type of app: desktop application and its name Lambda Gmail customer.
-
Click Create and download
client_secret_xxx.json
file.
-
-
Getting distinctive symbols to reach and update:
-
Make sure you have the right Python libraries installed on your local device ::
pip install google-auth-oauthlib google-api-python-client
-
Use the following Python text program to create symbols (replace “Path/To/Client_secret.json” with the path to the downloaded JSON file):
-
Run this Python text program to generate distinctive symbols to access and update:
from google_auth_oauthlib.flow import InstalledAppFlow scopes = ['https://mail.google.com/'] flow = InstalledAppFlow.from_client_secrets_file( 'path/to/your/client_secret.json', scopes) credentials = flow.run_local_server(port=0) print(f"Access Token: {credentials.token}") print(f"Refresh Token: {credentials.refresh_token}")
-
When you run the text program, you will be asked to log in to your Gmail account and delegate the application in the browser window after running the text program.
-
ACCESS_TOKEN and Refresh_token copy for later use.
-
Step 2: Storage Gmail Oauts in AWS Secrets
To store Gmail accreditation data safely, use AWS Secrets Manager. To do this, follow these steps:
-
Go to the AWS console and select Manager Manager.
-
Click Store a new secret and select another type of secret.
-
Copy and paste the following main value pairs:
- Gmail_client_id (from Client_secret.json)
- Gmail_client_secret (from Client_secret.json)
- Access_token (from Python Text Program)
- Refresh_token (from Python)
-
Click Next, enter the secret name as Gmailauauthsecrets and click the store.
-
Remember the secret of ARN to be used in Lambda.
Step 3: Create a SNS theme for notifications
To notify users when creating e -mail drafts, prepare Amazon SNS. To do this, follow these steps:
- Go to the AWS console and select SNS from the search bar.
- Choose standard and then click Create a theme.
- The name of the new topic is e-mail Click Create a topic.
- The ARN topic is copied to use later.
- Click Create a subscription, select the protocol and then select the email, then enter your email and confirm.
Step 4:
Create the IAM role for Lambda for Lambda to work, as it requires permission to work with other AWS services.
-
Go to the AWS console and select IAM from the search.
-
Click on the roles and select the role, then choose the AWS service and then Lambda.
-
Attach the following policies:
- A
- AmazonsnsFullacess (for notifications)
- Secretsmanagerredwrite (for the storage of Gmail accreditation data)
- Amazoncomprehendfullacess (for emotional analysis)
- Amazonbedrockfullacessss (for the responses created from artificial intelligence)
-
The role is named after Lambdaemailprocsus and then click Create a role.
Step 5: Prepare Amazon Amazon Rock for the response of Amnesty International
First, verify that the Amazon foundation is operated in the United States-1.
-
Go to the Amazon rock in the AWS control unit.
-
In accessing the model, enabling Amazon Titan Text G1 – Premier or any other model you prefer.
-
Accept the arrival request.
Step 6: Create and publish Aws Lambda function
Lambda function will process emails, analyze feelings, create responses and preserve drafts.
- Go to the AWS control unit; Select Lambda from searching and creating a job.
- Choose an author from zero, called “Emailoreplyprocessor” and choose Python 3.9.
- Set the role of iam “Lambdaemailproprocessor”.
- Requirement of the required dependencies:
pip install boto3 google-auth-oauthlib google-auth-httplib2 google-api-python-client -t lambda_package/
-
Save the Lambda code (shown below) as Lambda_package/Lambda_function.PY.
import json import os import boto3 from google.oauth2.credentials import Credentials from googleapiclient.discovery import build from google.auth.transport.requests import Request import base64 import re from googleapiclient.errors import HttpError # AWS Clients secrets_manager = boto3.client('secretsmanager') comprehend = boto3.client('comprehend') bedrock = boto3.client('bedrock-runtime') sns = boto3.client('sns') def extract_sender_name(sender_email): """ Extracts the sender's name from the email 'From' field. Example: - 'John Doe <[email protected]>' → 'John Doe' - '[email protected]' → 'John' """ match = re.match(r'(.+?)\s*<.*?>', sender_email) if match: return match.group(1).strip() # Extract name from 'John Doe
' else: return sender_email.split('@')[0].capitalize() # Fallback: Extract name from '[email protected]' def lambda_handler(event, context): try: # Retrieve OAuth credentials from AWS Secrets Manager secret_arn = os.environ['SECRET_ARN'] secret = secrets_manager.get_secret_value(SecretId=secret_arn) secret_json = json.loads(secret['SecretString']) creds = Credentials( token=secret_json.get('access_token'), refresh_token=secret_json['refresh_token'], client_id=secret_json['gmail_client_id'], client_secret=secret_json['gmail_client_secret'], token_uri='https://oauth2.googleapis.com/token' ) if creds.expired and creds.refresh_token: print("Refreshing token...") creds.refresh(Request()) secret_json['access_token'] = creds.token secrets_manager.put_secret_value(SecretId=secret_arn, SecretString=json.dumps(secret_json)) print("Token refreshed") # Build Gmail API client service = build('gmail', 'v1', credentials=creds) print("Gmail API client built") # Fetch unread emails results = service.users().messages().list(userId='me', labelIds=['UNREAD']).execute() messages = results.get('messages', []) print(f"Found {len(messages)} unread emails") if not messages: print("No unread emails found.") return {'statusCode': 200, 'body': 'No unread emails'} drafts_created = 0 for msg in messages: message = service.users().messages().get(userId='me', id=msg['id'], format='full').execute() headers = {h['name']: h['value'] for h in message['payload']['headers']} subject = headers.get('Subject', 'No Subject') sender = headers.get('From', 'Unknown Sender') # Extract sender's name sender_name = extract_sender_name(sender) print(f"Extracted sender name: {sender_name}") body_data = message['payload'].get('body', {}).get('data', '') text = base64.urlsafe_b64decode(body_data).decode('utf-8', errors='ignore') if body_data else message.get('snippet', '') print(f"Processing email from {sender}: {subject}") print(f"Email content: {text}") # Perform Sentiment Analysis sentiment_response = comprehend.detect_sentiment(Text=text[:5000], LanguageCode='en') sentiment = sentiment_response['Sentiment'] print(f"Sentiment: {sentiment}") if sentiment in ['POSITIVE', 'NEGATIVE']: # Enhanced AI Prompt for Titan Model prompt = f""" You are an AI email assistant drafting a professional reply to an unread email received by the user. You are replying as the recipient of the email to the sender, whose name is '{sender_name}'. **Rules:** - Maintain a **formal and professional tone**. - Address the sender’s intent directly (e.g., respond to offers or questions). - Do not include a greeting (e.g., 'Dear {sender_name}') or closing (e.g., 'Best regards')—focus only on the response body. - Do not copy the sender’s words; write an original response. - Adapt tone based on sentiment: - If positive, keep it warm and appreciative. - If negative, be empathetic and professional. - Confirm interest in opportunities and ask about next steps if applicable. **Email Received:** From: {sender} Subject: {subject} Content: --- {text[:1000]} --- **Draft the response body:** """ try: # Invoke Amazon Bedrock bedrock_response = bedrock.invoke_model( modelId='amazon.titan-text-lite-v1', body=json.dumps({ "inputText": prompt, "textGenerationConfig": { "maxTokenCount": 300, "temperature": 0.5, "topP": 0.9 } }) ) reply_body = json.loads(bedrock_response['body'].read())['results'][0]['outputText'].strip() print(f"Generated AI Reply: {reply_body}") except Exception as e: print(f"Bedrock error: {str(e)}") raise # Check for any greeting or closing in the AI response (case-insensitive) reply_body_lower = reply_body.lower() greeting_patterns = [f"dear {sender_name.lower()}", f"hello {sender_name.lower()}", f"hi {sender_name.lower()}", "dear", "hello", "hi"] closing_patterns = ["best regards", "sincerely", "kind regards", "thank you", "regards"] reply_has_greeting = any(pattern in reply_body_lower for pattern in greeting_patterns) reply_has_closing = any(pattern in reply_body_lower for pattern in closing_patterns) # Add greeting and closing only if missing if not reply_has_greeting: reply_body = f"Dear {sender_name},\n\n{reply_body}" if not reply_has_closing: reply_body += "\n\nBest regards,\nYour Name" try: # Create draft email draft_message = f"To: {sender}\nSubject: Re: {subject}\n\n{reply_body}" draft = { 'message': { 'raw': base64.urlsafe_b64encode(draft_message.encode('utf-8')).decode('utf-8') } } print(f"Creating draft: {draft_message}") service.users().drafts().create(userId='me', body=draft).execute() drafts_created += 1 print("Draft created successfully") except HttpError as e: print(f"Draft creation failed: {e}") # Send SNS Notification if drafts_created > 0: sns.publish( TopicArn=os.environ['SNS_TOPIC_ARN'], Message=f"{drafts_created} new email drafts created. Please review in Gmail." ) print("SNS notification sent") return {'statusCode': 200, 'body': f'Processed {len(messages)} emails, created {drafts_created} drafts'} except HttpError as error: print(f"Gmail API error: {error}") return {'statusCode': 500, 'body': f'Gmail API error: {error}'} except Exception as e: print(f"Error: {str(e)}") return {'statusCode': 500, 'body': f'An error occurred: {str(e)}'} -
Publication of the code:
-
Lambda_Package folder:
cd lambda_package zip -r ../lambda_function.zip .
-
In the LAMBDA control unit, select the code tab, click download from the .zip file, and download Lambda_function.zip.
-
-
Environmental variables:
-
Go to the configuration; Select the environment variables and click Edit.
-
Add the following values:
Secret_ARN: ARN Director (Step 2)SNS_TOPIC_ARN: Your SNS theme ARN (Step 3)
-
Click the Save button.
-
-
Appointment of the deadline:
Under the composition, select the general configuration and click the “Edit” button, then set the deadline to 5 minutes to accommodate the processing of multiple emails.
Step 7: Learn to implement the workflow automation using Amazon Eventbridge
- Go to the AWS console and select Eventbridge and create the base.
- His name is Gmail-UAUTOREPLY-SHEDULE.
- To express the schedule, mode: average (2 hours)
- For goals, choose the Lambda function and select Emailoreplyprocess.
- Click Create a base.
Step 8: Review and send emails in Gmail
Review the final outputs of Autoresponder AI in your Gmail account at the end of the process.
- Log in to your Gmail account.
- Go to the draft folder.
- Read through both drafts created from artificial intelligence, make any necessary changes, then send each of them manually when finished.
I did not build it
These steps were verified and have successfully created Autorsboster AI, an artificial intelligence -based email:
- Check your inbox in Gmail, every two hours of new non -readable messages.
- Amazon uses an understanding to determine these emails.
- To free emails that need your attention, it is a professional responsibility with the help of the Amazon foundation.
- It also organizes drafts for you in Gmail.
- He teaches you through Amazon SNS when there are new drafts.
This is a safe, cost -effective solution and full customization. Get a better and more efficient way to work with emails with Autorsboster AI!
Enjoy!