Skip to content

awsdataarchitect/agentic-meme-generator

Repository files navigation

Deploying a schedule-based Serverless Strands Agent on AWS Lambda with CDK, EventBridge and Docker

Try It Yourself

Want to build your own agentic meme generator? Here's how to get started:

Architecture

  1. Clone the repository:

    git clone https://github.com/awsdataarchitect/agentic-meme-generator
    cd agentic-meme-generator
  2. Install dependencies:

    pip install -r requirements.txt
  3. Set up Twilio for WhatsApp messaging:

    • Sign up for a free Twilio account at https://www.twilio.com/try-twilio
    • Navigate to the Twilio Console and note down your Account SID and Auth Token
    • Enable the WhatsApp Sandbox in the Messaging section
    • Follow the instructions to connect your WhatsApp number to the sandbox by sending the provided code
    • Note: The sandbox allows you to send 9 free messages every 24 hours for testing
  4. Configure your environment variables:

    export TWILIO_ACCOUNT_SID=your_account_sid
    export TWILIO_AUTH_TOKEN=your_auth_token
    export BEDROCK_WHATSAPP_TO=your_whatsapp_number  # Format: whatsapp:+1234567890

    You can test your Twilio setup with this simple Python script:

    from twilio.rest import Client
    
    client = Client("your_account_sid", "your_auth_token")
    message = client.messages.create(
        body="Test message from Twilio",
        from_="whatsapp:+14155238886",  # Twilio's sandbox number
        to="whatsapp:+1234567890"  # Your WhatsApp number
    )
    print(f"Message sent with SID: {message.sid}")
  5. Deploy with CDK:

    cd agentic-meme-generator
    npm install
    npm run build
    cdk deploy
  6. Trigger a meme generation manually on ad-hoc basis (if needed for testing):

    # Simpler approach using cli-binary-format
    aws lambda invoke \
      --region us-east-1 \
      --function-name AgenticMemeGenerator \
      --payload '{"body": "{\"theme\": \"standard\"}"}'  \
      --cli-binary-format raw-in-base64-out \
      /tmp/lambda-output.json

About

Deploying the schedule-based Serverless Strands Agent on AWS Lambda with CDK, EventBridge and Docker

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published