Build GenAI-Integrated Serverless Contact Forms for Static Websites With AWS Lambda, API Gateway, Bedrock, and SES
This repository contains the necessary code and resources to implement a serverless contact form solution integrated with GenAI capabilities. For detailed instructions on how to implement and deploy this solution, please refer to the associated documentation.
lambda_function.py
: Main Lambda function for handling contact form submissions and generating AI quoteslambda_test_event.json
: Sample test event for the contact form Lambda functiontemplate.py
: Template generator for AI inspirational quotesmain.js
: JavaScript code for contact form submission handlingHTML5 UP Dimension Template
: Template for the static website, including the contact form
This architecture enables dynamic functionality for static websites without traditional server management, handling form processing, AI integration, and email communication seamlessly in the cloud. The serverless contact form solution follows these steps:
-
A static contact form on the website initiates the process.
-
When a visitor submits the form, it sends an HTTP POST request to Amazon API Gateway.
-
API Gateway receives this request and invokes the AWS Lambda function.
-
The Lambda function, the core of the solution:
- Processes the form data
- Contains a pre-defined prompt for inspirational quote generation
- Invokes the Amazon Bedrock API with this prompt
-
Amazon Bedrock processes the prompt and generates a unique inspirational quote.
-
The Lambda function then:
- Receives the response from the Bedrock API
- Initiates the email-sending process using Amazon Simple Email Service (SES)
-
Amazon SES handles the email delivery:
- Sends a notification email to the website owner
- Sends a confirmation email, including the inspirational quote, to the website visitor
- AWS Lambda: Core logic for data processing and service orchestration
- Amazon API Gateway: RESTful API endpoint for the contact form
- Amazon Bedrock: AI service for generating inspirational quotes
- Amazon SES: Email delivery service
I'd love to connect with you and hear about your experiences with this project.