drupal / ai_recipe_basic_rag_chatbot
Provides basic implementation of 'Talk to your content' feature.
Package info
git.drupalcode.org/project/ai_recipe_basic_rag_chatbot.git
Type:drupal-recipe
pkg:composer/drupal/ai_recipe_basic_rag_chatbot
Requires
- drupal/ai_agents: ^1.2
- drupal/ai_recipe_content_search_vector: 1.x-dev@dev
- drupal/core: ^10.5 || ^11.2
This package is auto-updated.
Last update: 2026-06-11 13:14:45 UTC
README
Adds a "Talk to your content" chatbot to the Drupal admin interface. Editors can ask natural-language questions and the AI agent searches a vector index of site content, returning relevant answers with source links.
Requirements
- Drupal 10.5+ or 11.2+
- AI module with a configured default provider for:
embeddings— used to index content into the vector store (e.g. OpenAItext-embedding-3-small)chat_with_tools— used by the agent to reason and call the RAG search tool (e.g. OpenAI GPT-4o, Claude Sonnet)
- A vector-capable database backend supported by
search_api_ai_search(e.g. PostgreSQL with pgvector, configured via the database settings in thecontent_vectorserver)
Configure default providers at /admin/config/ai/settings → Default Providers.
Apply
composer require drupal/ai_recipe_basic_rag_chatbot
php core/scripts/drupal recipe recipes/contrib/ai_recipe_basic_rag_chatbot
drush cache:rebuild
If chat_with_tools has no default model configured, the recipe apply
will abort and roll back. Configure a default model and re-run.
What it does
Transitively applied: ai_recipe_content_search_vector
- Installs
node,search_api, andai_search. - Requires a default
embeddingsprovider to be set. - Creates a Search API server (
content_vector) using thesearch_api_ai_searchbackend with contextual-chunks embedding strategy (chunk size 1000, overlap 100). - Creates a Search API index (
content_vector) that indexes all node bundles with three fields: rendered HTML output (anonymous view),title, and absoluteurl. - Clones the Default view display of every node type into a
search_indexview mode used for the rendered HTML field.
This recipe
- Installs
ai_agents,ai_chatbot, andmodeler_api. - Creates a Content Search Assistant AI agent
(
content_search_assistant) configured as an orchestration agent with:- Up to 3 reasoning loops.
- The
ai_search:rag_searchtool locked to thecontent_vectorindex, returning up to 5 results with a minimum relevance score of 0.2. - A system prompt that instructs the agent to search before answering,
reply in the language of the question, and append source links in
[Read more](URI)/[Title](URI)format.
- Creates an AI Assistant (
content_search_assistant) backed by the agent above, using the default LLM provider, with session-based conversation history (2-message context window). - Places an
ai_deepchat_blockblock (label: Search Chatbot, bot name: Talk to your content) in thecontentregion of the active admin theme (Gin or Claro), visible only to authenticated users.
Using the chatbot
Index your content — after applying the recipe, trigger an initial index run:
drush search-api:index content_vectorOr visit Configuration → Search API → Content Vector and click Index now. New and updated nodes are indexed automatically on save (
index_directly: true); cron processes up to 5 items per run as a fallback.Open the chatbot — log in as any authenticated user and navigate to any admin page. The chatbot widget appears in the content area.
Ask a question — type a question in natural language. The agent will search the vector index, synthesise an answer, and include links to the relevant pages.
Customising the agent behaviour
The agent's system prompt and tool constraints can be edited at
Configuration → AI → Agents → Content Search Assistant
(/admin/config/ai/agents/content_search_assistant):
- Max results / min score — adjust the
amount(default 5) andmin_score(default 0.2) tool usage limits to trade recall vs. precision. - Max loops — increase beyond 3 if complex queries need more search-then-reason iterations.
- System prompt — rewrite the instructions to change tone, language behaviour, or link formatting.
The chatbot block settings (placement, first message, theme) can be adjusted at Structure → Block layout.
Cost note
Every chatbot turn triggers at least one embeddings call (to vectorise
the query) and one chat_with_tools call (the agent reasoning step),
plus additional tool calls per loop iteration. High-traffic sites or
complex multi-loop queries will incur proportional API costs. Review your
provider's pricing before exposing the chatbot to a large authenticated
user base.
Issue queue
Bugs and feature requests: https://www.drupal.org/project/issues/ai_recipe_basic_rag_chatbot