Technical Talent →

AEM + AI Search: Building a RAG-Powered Chat Assistant On Top of Your AEM Content

Why Bolting On a Chatbot Usually Fails

The common failure pattern: a team stands up a chatbot, exports AEM content into a third-party vector database once, and ships it. Three months later the bot is confidently answering with a pricing page that was updated twice since launch. The bot didn’t get worse and the content just moved on without it.

The fix isn’t a smarter model. It’s treating AEM as the live source of truth and re-indexing on publish, the same way search engines re-crawl a site except here, you control the trigger and the latency is minutes, not weeks.

Layer 1 – Content Ingestion: Turning Pages Into Retrievable Chunks

An AEM publish-event listener triggers an App Builder action that extracts the actual content body copy, FAQ entries, product specs from each page’s Content Fragments, splits it into semantically coherent chunks, and generates an embedding for each chunk.

  • Publish-triggered, not scheduled – a page update re-indexes within minutes, not on a nightly batch job
  • Content Fragment aware – structured fields stay structured instead of being flattened into raw HTML text
  • Chunk-level metadata – each chunk carries its source URL, last-modified date, and locale for accurate citation later
Layer 2 – Retrieval: Finding the Right Chunks, Not Just Similar Ones

Hybrid retrieval combines vector similarity with keyword (BM25) scoring and re-ranks the combined results, so an exact phrase match isn’t buried under vaguely-similar embeddings.

Layer 3 – Claude API: Answering With Citations, Not Guessing

Claude is instructed to answer only from the retrieved chunks passed in the prompt and to say so explicitly when the retrieved content doesn’t cover the question, rather than filling the gap from general knowledge.

Why this matters: Grounding the model in retrieved AEM content and instructing it to decline unanswerable questions is what turns a chatbot from a liability into a trustworthy self-service channel.

Where the Assistant Lives
  • On-site search bar – replaces keyword search with a conversational answer plus links to source pages
  • Embedded chat widget – a persistent assistant available across the AEM Edge Delivery site
  • Authoring-side Q&A – inside the Universal Editor, authors can check for existing content before creating a duplicate
Guardrails: What Not to Let It Answer

Scope the assistant deliberately: RAG reduces hallucination but doesn’t eliminate the risk of an ungrounded or out-of-scope answer. Explicitly exclude regulated topics such as medical advice, legal guidance, financial commitments from the retrievable content set, and have the assistant hand off to a human channel instead.

Log every query alongside which chunks were retrieved and whether the model answered or declined. This log is the fastest way to find content gaps.

Implementation Checklist
  • Build an App Builder action triggered on AEM publish events to chunk and embed content automatically
  • Keep Content Fragment structure intact in chunk metadata instead of flattening to raw text
  • Implement hybrid retrieval vector similarity plus keyword scoring, merged via reciprocal rank fusion
  • Instruct Claude to answer only from retrieved context and explicitly decline unanswerable questions
  • Attach source path and last-modified date to every chunk for accurate citation
  • Exclude regulated content categories from the retrievable set and route those queries to a human channel
  • Log every query, retrieved chunks, and whether the model answered or declined
  • Review the decline log weekly as a content-gap signal for the editorial team
What to Measure
  • Answer rate – percentage of queries the assistant answers vs explicitly declines
  • Citation accuracy – spot-check that cited sources actually support the claim made
  • Re-index latency – time between a page publish and that content becoming retrievable
  • Deflection rate – self-service resolutions that would otherwise have become a support ticket
Final Thoughts

The sites winning on search in 2026 didn’t buy a smarter chatbot. They stopped treating search as a separate system with its own stale copy of the content, and started treating AEM as the one place content lives with retrieval and generation built on top of it, refreshed the moment something is published.

Start with one content area support or product docs prove the answer rate and citation accuracy, then expand the retrievable set from there.