DEV Community

Cover image for Multichannel AI Agent: Shared Memory Across Messaging Platforms
Elizabeth Fuentes L for AWS

Posted on

Multichannel AI Agent: Shared Memory Across Messaging Platforms

Build an AI chatbot that remembers users across WhatsApp and Instagram using Amazon Bedrock AgentCore, unified identity, and DynamoDB message buffering

You send a video on WhatsApp. You switch to Instagram. You ask about the video. The chatbot has no idea what you are talking about. Most AI chatbots treat every channel as a separate conversation with no shared context, no shared memory, and no continuity. I built a multichannel AI agent that solves this problem using Amazon Bedrock AgentCore.

One deployment serves both WhatsApp and Instagram with shared memory. The agent remembers your name, your photos, your videos, and your preferences regardless of which channel you write from.

Assumes familiarity with AWS CDK, AWS Lambda, and WhatsApp/Instagram API concepts. Deployment takes approximately 15 minutes per stack.

What does a multichannel AI agent with shared memory look like?

Here is the agent processing different media types on WhatsApp and responding on Instagram with full context.

How does the AI agent process voice notes on WhatsApp?

The agent transcribes voice messages automatically using Amazon Transcribe and responds based on the spoken content. The transcription is stored in memory so the agent can reference it in future conversations.

AI agent transcribing and responding to a WhatsApp voice note in real time using Amazon Transcribe

How does the AI agent analyze videos on WhatsApp?

Send a video and the agent uploads it to TwelveLabs for visual and audio analysis. It describes the content in detail and stores a reference ID so you can ask follow-up questions about the same video later.

How does the AI agent analyze images on WhatsApp?

Send a photo and the agent describes the visual content, answers questions about it, and stores the description in long-term memory. You can ask about the same image days later and the agent recalls the details.

AI agent describing an image sent on WhatsApp using Claude vision and storing the description in Amazon Bedrock AgentCore Memory

How does cross-channel memory work between WhatsApp and Instagram?

Switch to Instagram. The agent recognizes you by name, knows your preferences, and remembers what you shared on WhatsApp. This works because both channels share the same actor_id in AgentCore Memory.

AI agent on Instagram recognizing a user by name and recalling images and videos shared on WhatsApp through cross-channel memory

How does the architecture work?

The project uses three independent AWS CDK stacks that share configuration through AWS Systems Manager Parameter Store:

Architecture diagram showing three CDK stacks: AgentCore Runtime with Memory, WhatsApp via SNS, and multichannel API Gateway with DynamoDB buffering for WhatsApp and Instagram

Stack Purpose Integration path
Stack 00 AI agent with persistent memory Amazon Bedrock AgentCore Runtime + Memory
Stack 01 WhatsApp only AWS End User Messaging Social (SNS-based)
Stack 02 WhatsApp + Instagram Amazon API Gateway webhook, single endpoint for both platforms

The agent uses AgentCore Memory with two layers of persistence:

  1. Short-term memory: Conversation turns within a session. Expires after a configurable TTL (Time To Live).
  2. Long-term memory: Extracted facts, preferences, and summaries. Persists indefinitely across all sessions and channels. The extraction happens asynchronously in the background.

How does unified identity work across WhatsApp and Instagram?

When you write from WhatsApp, the system creates a deterministic user ID based on your phone number (wa-user-{phone}). When you link your Instagram account, both channels resolve to the same ID. The actor_id sent to AgentCore Memory is identical regardless of channel.

The linking happens through conversation. The agent asks new users if they also write from another channel. If you share your Instagram username or WhatsApp number, a link_account tool merges both identities in a unified users DynamoDB table.

Channel User ID format Lookup method
WhatsApp first wa-user-{phone} GSI on wa_phone
Instagram first ig-user-{sender_id} GSI on ig_id, fallback scan on ig_username
Linked Whichever was created first Both GSIs resolve to the same record

How does message buffering reduce AI invocation costs?

WhatsApp users tend to send 3-5 rapid messages instead of one long text. Without buffering, each message triggers a separate AI invocation, multiplying cost and token usage.

A DynamoDB Streams tumbling window accumulates messages from the same user for 10 seconds, then sends them as a single concatenated prompt to the agent.

User sends 3 messages in 2 seconds:
  "hello"             -> DDB INSERT (t=0s)
  "I have a question"  -> DDB INSERT (t=1s)
  "about my video"     -> DDB INSERT (t=2s)

Tumbling window fires at t=10s:
  -> Processor receives all 3 records in one batch
  -> Aggregates: "hello\nI have a question\nabout my video"
  -> Single AgentCore invocation
Enter fullscreen mode Exit fullscreen mode

This pattern is based on Enrique Rodriguez's sample-whatsapp-end-user-messaging-connect-chat, which reported a 4:1 aggregation ratio in real-world WhatsApp usage.

What media types does the AI agent support?

Media Processing method Memory storage
Text Direct prompt to the agent Stored as conversation event
Image Anthropic Claude vision describes the content Text description stored in long-term memory
Audio and voice notes Amazon Transcribe converts speech to text Transcription stored as text prompt
Video TwelveLabs Pegasus analyzes visual and audio content Description and reference ID stored in long-term memory
Documents (PDF, DOCX, XLSX) Claude reads inline and summarizes Summary stored in long-term memory

All multimedia is converted to text understanding before entering memory. This is how the agent recalls what was in a photo or video days later, even across channels.

Frequently asked questions

Can the same agent serve WhatsApp and Instagram at the same time?
Yes. Stack 02 uses a single API Gateway webhook that receives both WhatsApp and Instagram messages. The receiver Lambda detects the channel from the payload and normalizes both into a common format.

Does the agent remember conversations when switching channels?
Yes. A unified users table maps WhatsApp phone numbers and Instagram IDs to a single user. When both accounts are linked, the agent uses the same actor_id in AgentCore Memory. Long-term facts and preferences persist across both channels.

What happens if I only want WhatsApp without Instagram?
Deploy Stack 01 for WhatsApp via AWS End User Messaging, or deploy Stack 02 and configure only the WhatsApp secret. The agent works without Instagram when no Instagram credentials are configured.

How can I add more channels like Telegram or a web chat?
The AgentCore Runtime and Memory layer is channel-agnostic. To add a new channel, create a receiver that normalizes messages into the same DynamoDB format and add a reply dispatch function. The agent and memory work without changes.

Get started

The full project with deployment instructions, Instagram setup guide, and architecture documentation:

github.com/elizabethfuentes12/whatsapp-ai-agent-sample-for-aws-agentcore

This is a demo project for learning and experimentation. If you plan to use these patterns in production, add proper security hardening, error handling, and monitoring.

Built with Amazon Bedrock AgentCore, AWS CDK, and Strands Agents. Similar patterns can be applied using LangGraph, AutoGen, or the Amazon Bedrock Agents SDK.


Gracias!

🇻🇪🇨🇱 Dev.to Linkedin GitHub Twitter Instagram Youtube
Linktr

Top comments (0)