AI Chatbot
What is the AI Chatbot module?
The AI Chatbot module provides a user interface for chatbot interactions, consisting of a block with a text-input that processes user messages through ChatProcessor plugins and renders AI responses as user-readable text.
ChatProcessor Plugin System
The module uses the AI module's ChatProcessor plugin system to process chat input and generate responses. This decouples the UI from the processing logic, allowing for:
- Custom chatbot behaviors (RAG, tool use, etc.)
- Integration with different AI services
- Specialized processing workflows
- Backward compatibility with AI Assistant API
For information on creating custom ChatProcessor plugins, see Writing a ChatProcessor Plugin.
Built-in Plugins
The module includes two reference implementations:
- AI Assistant API Processor: Provides backward compatibility with the existing AI Assistant API
- RAG Processor: Simple RAG (Retrieval-Augmented Generation) implementation
Dependencies
- The AI module must be installed and configured.
- At least one Provider module must be enabled and configured.
How to configure the AI Chatbot module
- Enable the AI Chatbot module.
- Visit /admin/structure/block
- Choose a region of your theme template and click the "place" button.
- Select the AI Chatbot block and press the place button.
- Configure the block:
- Give it an admin name and user-facing label
- Make sure to not show the label.
- Select which ChatProcessor plugin to use.
- Provide an initial statement to use shown to the user.
Token-based avatars
The Default Avatar field in the chatbot block settings accepts Drupal tokens, allowing you to dynamically resolve the avatar image for each user. For example:
[current-user:user_picture]— uses the user's picture field.[current-user:profile_type:field_name]— uses an image field from a Profile entity (requires the Profile module). Replaceprofile_typewith the machine name of the profile type andfield_namewith the image field name, e.g.[current-user:admin_profile:field_profile_image:entity:url].
When a token resolves to an <img> HTML tag, the src URL is automatically
extracted. If the token produces no result, the block falls back to the user's
user_picture field. If that is also empty, no avatar is displayed.
How to use the AI Chatbot
When an AI Chatbot block is placed on a page, it will display its label to the user. If the user clicks it, it will open a form to allow the user to pass messages via the configured ChatProcessor plugin and see the responses.
The message history can be retained inside the block until the page is reloaded or the user navigates away, depending on settings.
Customize the Chatbot
The Chatbot is based on Deepchat by OvidijusParsiunas and can be customized both in look and feel. The designing of the chatbot is done via attributes, see the documentation on deepchat.dev, but we have abstracted it away into yaml files.
You can in your active theme add a folder called deepchat_styles and load your own custom themes to use.
There is also a hook called hook_deepchat_settings where you can change the attributes on the fly.