Inspiration

The main problem statement of the hackathon is "solve real-world business problems". So, we ventured to find some problems to solve that are the right fit to lambda to their core. We surveyed among the friends and stranger alike. Talking to people who own businesses, Cafes, restaurants, etc. It was then we got to know about the difficulty, we call "lack of reach", these businesses face just after their inception, arguably the MOST crucial time. No matter the quality, vision, dedication that goes into their craft, the businesses barely get any attention from people. This can be due to number of reasons, but most common reason among new businesses is lack of a dedicated marketing campaign or person.

THIS was our inspiration. It is also a perfect fit to event-driven style that serverless architectures feed on. And with the help of their credits and community (shoutout to Eric, Carole, Kim, Shun, Chris) backing us and supporting us, we really needed go all out on this project. Introducing AdGenie, a robot marketing intern. This intern will completely do all your marketing with little to no guidance, minimal wages and with no leaves :)

What it does

AdGenie is an AI-powered application that acts as a "marketing intern" for businesses big and small, that is built to scale infinitely. It automatically generates posts and publishes hyper-relevant social media content to Instagram based on real-world triggers, like rainy, hot and sunny, weekday sales, anniversary sales, boss's birthday, etc. completely customized by the user. The best part? It needs no guidance but a one-time 5 min setup, little revenue and can serve thousands of businesses all at once thanks to AWS Lambda.

The platform operates in four distinct stages, from initial setup to final post.

1. 5-minute one time business Onboarding: ** A business owner signs up through the React frontend published and made available using _AWS Amplify*_. A suite of RESTful Lambda functions exposed via API Gateway handles the core CRUD operations for their business profile, which is stored in *AWS DynamoDB**. To connect their Instagram account, the user is guided through an OAuth 2.0 flow, after which we store long-lived Instagram API token securely along with the business's profile.

2. Trigger Activation: After the businesses onboarding, they get to choose when the app (or rather the intern) should post. AdGenie's Lambda backend constantly monitors for opportunities based on these user-configured triggers. This is not a simple cron job, but a collection of specialized, event-driven processes made from different AWS Services like SQS, EventBridge and EventBridge Scheduler:

  • Time-Based Triggers: ** A scheduled Lambda, runs daily. It scans for users who have opted into time-based campaigns (like "Payday Sales" or "Weekend Specials"). When a relevant day is identified, it uses **AWS EventBridge Scheduler to create a precise, one-off job to generate an ad at 10:00 AM in the business's local timezone.
  • *Weather-Based Triggers: * A more advanced scheduled Lambda, check_weather, runs periodically via Event Bridge Schedules. For each opted-in business, it does the following
    • fetches 30 days of historical weather data from the Open-Meteo API to establish a local baseline for "hot" or "cold".
    • It then analyzes the next 12-hour forecast for sustained conditions that match the business's preferences (e.g., "post when it's rainy").
    • If a valid event is detected within the business's operating hours, it schedules a targeted ad generation job via EventBridge Scheduler.
  • *On-Demand Triggers: * The user can manually trigger ad generation at any time through invoking the ad_generation lambda with prompt of their choice, perfect for flash sales or special announcements like Birthday sales, clearance sales, etc.

3. AI-Powered Generation: When a trigger fires—either from a scheduled job or an on-demand request—an AI worker Lambda (bedrock_generate or ad_generation) is invoked. This function:

  1. Constructs a detailed prompt based on the business's profile stored in AWS DynamoDB (brand voice, products) and the specific trigger (e.g., "Rainy day special") from AWS SQS or AWS EventBridge.
  2. Uses Amazon Bedrock's Titan models(text-premier for caption, image v2 for posts) to generate a unique, on-brand caption and a compelling visual.
  3. Uploads the generated image to a private S3 bucket.
  4. Places a message containing the caption and a presigned URL for the image into an SQS queue, making the entire system decoupled and ready under loads!

4. Automated Instagram Posting: The SQS queue decouples generation from the final posting. The post_to_instagram Lambda is triggered by a new message in the AWS SQS queue. This function handles the complex, asynchronous process of publishing to the Instagram Graph API:

  1. It creates a media container on Instagram with the image URL.
  2. It polls Instagram with exponential backoff, waiting for the container to be processed.
  3. Once ready, it publishes the container, making the post live.
  4. Finally, it retrieves the post's permalink and updates the business's record in DynamoDB with a history of the post.

AWS Lambda: The Core of AdGenie

The entire backend is built on AWS Lambda, which provides a powerful, event-driven, and scalable foundation. This serverless approach was chosen for several key advantages.

Why Lambda is the Perfect Fit:

  • Event-Driven Architecture: The application's workflow is naturally event-driven, making Lambda an ideal choice. Functions execute in response to specific triggers, creating a loosely coupled and highly resilient system.
  • Cost-Efficiency: We only pay for the compute time we consume. When no triggers are firing, the cost is near zero. This is far more economical than maintaining idle servers.
  • Automatic Scaling: Lambda automatically scales in response to the number of incoming events. Whether one business or one thousand businesses have triggers fire at the same time, the system scales seamlessly without any manual intervention.
  • Reduced Operational Overhead: By using Lambda, we eliminate the need to provision, manage, patch, or scale servers, allowing us to focus entirely on application logic.

Lambda Trigger Mechanisms in AdGenie:

A total of 4 unique triggers were naturally required to be used by the problem statement: We leverage multiple trigger types to create a flexible and responsive system:

  • API Gateway: Used for synchronous, user-facing RESTful API calls. This provides the interface for the frontend to manage business profiles, handle OAuth callbacks, and request on-demand ad generation.
  • EventBridge Scheduler: The backbone of our proactive marketing. We use it for both:
    • Cron Jobs: Recurring schedules that invoke the check_weather and check_time_triggers functions.
    • One-Off Schedules: Dynamically created schedules that invoke the bedrock_generate function at a precise future time for a specific business.
  • SQS: Used for asynchronous processing. It decouples the potentially long-running Instagram posting process from the content generation step, improving reliability and ensuring that generation requests aren't lost if posting fails.

How we built it

We did go all out in this project since we got some free credits to work with, we focused on building a scalable, decoupled architecture first. So, we used quite a bit of services by Amazon. Here is the architecture diagram:

Architecture Diagram

AWS Services

  • Amazon API Gateway – REST interface that fronts all synchronous Lambda calls.
  • AWS Lambda – Execution environment for every micro-service function.
  • Amazon EventBridge   - Rule Scheduler for recurring cron jobs (check_time_triggers, check_weather).    - EventBridge Scheduler for one-off, time-targeted invocations of bedrock_generate.
  • Amazon SQS – Decouples AI generation from the posting workflow (ad_content_queue).
  • Amazon S3 – Stores Titan-generated images and serves presigned URLs.
  • Amazon DynamoDB – Persists business profiles, trigger settings, and posting history.
  • Amazon Bedrock – Hosts Titan text and image models used by bedrock_generate / ad_generation.
  • AWS CloudWatch Logs – Implicitly captures logs from every Lambda invocation (debugging & monitoring).
  • AWS IAM – Roles and policies that grant least-privilege access between services (e.g., Scheduler → Lambda, Lambda → S3).
  • AWS SAM - Finally the GOAT, for all the deployment, changes to permission, etc.

External / Non-AWS Services & Tools

  • Instagram Graph API – Publishes media and retrieves user profile data.
  • Open-Meteo API – Supplies real-time forecasts, historical averages, and geocoding for the weather-trigger engine.
  • geoapify - Provides auto completion for city location and provides coordinates based on the city name
  • draw.io / diagrams.net – Used for producing the architecture diagrams (design-time only).
  • React (Vite + TypeScript) – Frontend framework powering the SPA.
  • Python – Used python for writing Backend logic and lambda functions
  • Tailwind CSS & Shadcn/ui – UI styling and component libraries for the frontend.
  • Bun (package manager) / npm – JavaScript build and dependency tooling.
  • Adobe after effects - for beautiful illustrations and gifs for the project

Challenges We Faced

Fine-Tuning AI Prompts: Programmatically building effective prompts for the AI image generator was difficult. We had to combine the business's profile, products, and trigger context (like "rainy day") into a detailed prompt, which required extensive trial-and-error to get brand-consistent results.

Building the Decoupled Architecture: While powerful, implementing our architecture was complex. Configuring the intricate IAM permissions for each service to communicate securely and debugging issues across the distributed system proved to be significant hurdles.

Developing Weather Detection Logic: Defining a "hot" or "rainy" day isn't universal. Our challenge was creating a smart weather engine that fetches historical data to create a local baseline for a business, then intelligently analyzes the forecast against it—a task far more complex than a simple temperature check. We had to used normal distributions, standard deviations, rolling windows, etc.

Timezone headache: We are building this app for businesses all over the world, so we had to handle complex timezone conversions for creating a seamless experience. We had to handle timezone conversions for timezones =UTC separately before triggering lambda, invoking check weather or comparing forecast data with local businesses open timings.

Navigating the Instagram API: The Instagram API's asynchronous posting process was a major obstacle. It’s a complex three-step workflow (create container, poll for status, publish) that forced us to build a robust polling mechanism with exponential backoff to handle errors and rate limits.

Accomplishments that we're proud of

Building a truly automated, end-to-end system. We are extremely proud of successfully creating, not just a MVP or POC but a complete working "fire-and-forget" app that takes a business from a simple profile to a live, intelligently triggered Instagram post with no manual intervention. Test it yourself in your location. Create a sample business account and add your current location, you will see a post according to your local weather, payday etc.

Designing a robust, decoupled serverless architecture. We are proud of architecting a highly scalable and resilient system using a suite of AWS services. The use of SQS and EventBridge ensures that each component works independently, making the platform reliable under load.

Implementing sophisticated trigger logic. Moving beyond simple cron jobs, we built an advanced weather-trigger engine that analyzes historical data to determine local weather patterns, allowing for truly hyper-relevant content generation.

Mastering complex API integrations. We successfully navigated the complexities of the Instagram Graph API's asynchronous media publishing workflow, including handling polling with exponential backoff for a reliable posting mechanism.

What we learned

AWS SAM is a game-changer for serverless development. This project was a deep dive into using AWS SAM for infrastructure-as-code. We learned how it dramatically simplifies the process of defining resources, managing permissions (IAM roles), and deploying complex serverless applications. Huge thanks to serverless team for introducing me to this.

The power of decoupling with SQS. We learned firsthand how an SQS queue is essential for building resilient systems. It allowed us to separate the content generation step from the potentially slow or error-prone posting step, ensuring no data is lost and improving the user experience.

Dynamic scheduling with EventBridge Scheduler. We discovered the flexibility of EventBridge Scheduler for creating dynamic, one-off events. This was the key to scheduling posts in a business's specific timezone and was a more powerful tool than traditional cron jobs for our use case.

Practical prompt engineering. Generating useful and aesthetically pleasing content from AI models requires skill. We learned how to construct detailed, context-rich prompts for Amazon Bedrock by combining business data, brand voice, and trigger information to get high-quality results.

What's next for AdGenie

The possibilities are just endless for AdGenie. We already laid a decoupled, scalable foundation that can support millions of businesses with the help of lambda, event bridge, SQS and many other AWS services. That said, there are something we thought would be nice to have, but couldn't make it in the hackathon's timeline:

  1. Pre-defined post templates: We can have some predefined designs that business can pick from according to their style preferences.
  2. Holiday Trigger: We were also thinking of adding a holiday trigger to promote goodwill and discounts on behalf of businesses. If they wish to, of course.
  3. Fine-tuning image generation: Add ability to take input of images of actual Menu & cafe and generate based on that
  4. Tone training: Add custom tone functionality! The user pastes some of their captions from the past to get their generated captions in exact tone.
  5. Approval step: Add a review and approve step before posting, the businesses can edit the text before in goes live.

Built With

+ 9 more
Share this project:

Updates