The vf-chatbot
component enables conversational interaction between a user and an AI system. It is designed for flexibility and can be embedded in a page as a modal or accessed as a standalone solution.
While bots can be a solution to some business challenges, ensure that it is the right solution before implementing it. Consider the following:
The chatbot standalone and chatbot modal are two distinct variants for delivering conversational interfaces. Choose between them based on use case needs and task complexity.
Element | Description |
---|---|
Title bar | Shows the chatbot name, minimise button and close button. The title bar may include a dropdown for selecting categories. |
Dialogue section | Scrollable chat window showing the conversation log. |
Intro message | A brief onboarding message explaining the purpose and capabilities of the chatbot. Shows the icon, title and short message. |
Banner | Used to show optional disclaimers or alerts (Max. 3 lines of text). For cases that require user consent, use a blur overlay on the background or a pre-access popup instead, as banners may be missed. |
Text input area | Open input field for typing and sending queries. Expands up to 5 lines, after which it becomes scrollable. |
Flow | Details |
---|---|
Suggested prompts | Appear on the initial screen. Provide a quick start to users with clickable queries. They help to provide context on the type of questions the user can ask on the platform. (Max. 60 characters) |
Closing the chat dialogue | Clicking on the close icon "X" triggers a confirmation prompt to prevent accidental loss of the chat log. |
Error management | If the chatbot is unable to provide a response to the query, display a clear error message and provide an alternative way for them to get their answers. |
Links | Displayed in a clear underlined style. They can be shown inline or as a list. |
Source attribution | Chips are shown in relevant paragraphs which cite the sources. Links to the sources and more details can be accessed via a "View sources" button. |
Feedback on a query level | Users can assess the AI responses with a thumbs up/thumbs down or optional close/open response fields to give more details. |
Category selection | A dropdown in the title bar lets users switch focus areas (e.g LLM version or data source). Single or multi-selection variants can be used depending on the use case. |
The component targets WCAG 2.1 AA accessibility standard.
Depending on your environment you'll want to use render
or include
. As a rule of thumb: server-side use include
, precompiled browser use render
. If you're using vf-eleventy you should use include
.
include
You'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include
is an abstraction of render
and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type" : "container",
"title" : "AI Assistant",
"welcome_message" : "Hello! How can I help you today?",
"input_placeholder" : "Type your message...",
"show_suggestions" : true,
"disclaimer" : "Disclaimer: This chatbot is designed to assist you with general information and basic inquiries. See our <a class="vf-banner__link" href="https://www.ebi.ac.uk/data-protection/privacy-notice/embl-ebi-public-website/">disclaimer notes</a>.",
"footnote" : "Review AI generated content for accuracy. <a class='vf-link' href='https://embl.service-now.com/esc?id=sc_cat_item&sys_id=5eeb8eb91b92e650b376da88b04bcbc1'>Leave feedback</a>.",
"callExternalAPI" : true,
}
%}
{% include "../path_to/vf-chatbot/vf-chatbot.njk" %}
render
This approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include
is not be available.
{% render '@vf-chatbot', {
"component-type" : "container",
"title" : "AI Assistant",
"welcome_message" : "Hello! How can I help you today?",
"input_placeholder" : "Type your message...",
"show_suggestions" : true,
"disclaimer" : "Disclaimer: This chatbot is designed to assist you with general information and basic inquiries. See our <a class="vf-banner__link" href="https://www.ebi.ac.uk/data-protection/privacy-notice/embl-ebi-public-website/">disclaimer notes</a>.",
"footnote" : "Review AI generated content for accuracy. <a class='vf-link' href='https://embl.service-now.com/esc?id=sc_cat_item&sys_id=5eeb8eb91b92e650b376da88b04bcbc1'>Leave feedback</a>.",
"callExternalAPI" : true,}
%}
<!-- Standalone Chatbot -->
<div class="vf-content vf-chatbot-standalone-container" data-vf-js-chatbot-standalone-container>
<div class="vf-chatbot-standalone__header">
<div class="vf-chatbot-standalone__header-left">
<div class="vf-chatbot-selector" data-vf-js-chatbot-selector data-routes-path="../../assets/vf-chatbot/assets/vf-chatbot-selector-services.json" data-multiselect="true" data-max-multiselect="3" data-show-search="true" data-show-all-services="true" data-show-all-services-selected="true">
<button class="vf-chatbot-selector__title" data-vf-js-selector-toggle>
<img src="../../assets/vf-chatbot/assets/vf-chatbot--icon-32x32-dark-green.svg" alt="AI Assistant">
<div class="vf-chatbot-selector__title-content">
<span class="vf-chatbot-selector__main-text">AI Assistant</span>
<span class="vf-chatbot-selector__title-text">Services</span>
</div>
<span class="vf-chatbot-selector__chevron">
<svg width="32" height="31" viewBox="0 0 32 31" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_3647_8230)">
<path d="M15.999 19.0975C15.7378 19.098 15.479 19.0468 15.2377 18.9468C14.9963 18.8469 14.7771 18.7001 14.5926 18.5151L8.32863 11.9279C8.21951 11.8137 8.13399 11.6791 8.07698 11.5318C8.01998 11.3845 7.99261 11.2274 7.99645 11.0695C8.00028 10.9116 8.03525 10.756 8.09934 10.6117C8.16342 10.4673 8.25537 10.337 8.36992 10.2283C8.48446 10.1195 8.61934 10.0344 8.76683 9.97791C8.91432 9.92139 9.07152 9.89454 9.2294 9.89889C9.38729 9.90325 9.54277 9.93872 9.68692 10.0033C9.83107 10.0678 9.96106 10.1602 10.0694 10.2751L15.7094 16.2143C15.7467 16.2537 15.7916 16.2851 15.8414 16.3066C15.8912 16.3281 15.9448 16.3391 15.999 16.3391C16.0533 16.3391 16.1069 16.3281 16.1567 16.3066C16.2065 16.2851 16.2514 16.2537 16.2886 16.2143L21.9286 10.2751C22.037 10.1602 22.167 10.0678 22.3112 10.0033C22.4553 9.93872 22.6108 9.90325 22.7687 9.89889C22.9266 9.89454 23.0838 9.92139 23.2312 9.97791C23.3787 10.0344 23.5136 10.1195 23.6282 10.2283C23.7427 10.337 23.8347 10.4673 23.8987 10.6117C23.9628 10.756 23.9978 10.9116 24.0016 11.0695C24.0055 11.2274 23.9781 11.3845 23.9211 11.5318C23.8641 11.6791 23.7786 11.8137 23.6694 11.9279L17.439 18.4991C17.2503 18.6888 17.0259 18.8394 16.7788 18.9421C16.5316 19.0448 16.2667 19.0976 15.999 19.0975Z" fill="#707372" />
</g>
<defs>
<clipPath id="clip0_3647_8230">
<rect width="16" height="16" fill="white" transform="translate(8 6.5)" />
</clipPath>
</defs>
</svg>
</span>
</button>
<div class="vf-chatbot-selector__dropdown" data-vf-js-selector-dropdown>
<div class="vf-chatbot-selector__search">
<input type="text" placeholder="Select services" data-vf-js-selector-search>
</div>
<div class="vf-chatbot-selector__header">
<span data-max-select="3">Select up to 3 services</span>
<a href="#" class="vf-chatbot-selector__clear" data-vf-js-selector-clear>Clear all</a>
</div>
<ul class="vf-chatbot-selector__list" data-vf-js-chatbot-selector-list>
<!-- Routes will be populated dynamically via JavaScript -->
</ul>
</div>
</div>
</div>
</div>
<div class="vf-chatbot-standalone | vf-u-background-color-ui--grey--light vf-u-margin__bottom--400" data-vf-js-chatbot-standalone>
<div class="vf-chatbot-standalone__content" data-vf-js-chatbot-standalone-content>
<!-- Chat interface -->
<!-- Initial welcome message from the assistant -->
<div class="vf-chatbot-welcome vf-u-padding__right--400" data-vf-js-chatbot-welcome data-max-questions="4">
<div class="vf-chatbot-welcome__content">
<div class="vf-chatbot-welcome__logo">
<img src="/assets/vf-chatbot/assets/vf-chatbot--icon-64x64-dark-green.svg" alt="AI Assistant">
</div>
<div class="vf-chatbot-welcome__title"></div>
<div class="vf-chatbot-welcome__description">
Welcome! I'm here to help
</div>
</div>
<div class="vf-chatbot-welcome__suggestions">
<p class="vf-chatbot-welcome__suggestions-title">Try asking me:</p>
<div class="vf-chatbot-welcome__suggestions-grid" data-vf-js-chatbot-welcome-suggestions-grid>
<!-- Suggestions will be populated dynamically from qa.json using the template below -->
</div>
</div>
<!-- Template for welcome suggestions using vf-chatbot-action-prompt -->
<template id="welcome-suggestion-template">
<div class="vf-chatbot-action-prompt">
<a href="#" class="vf-chatbot-action-prompt__link vf-u-padding--200">
</a>
</div>
</template>
</div>
<!-- Messages container -->
<div class="vf-chatbot-standalone__messages vf-u-padding__right--400" data-vf-js-chatbot-standalone-messages>
<!-- Messages will be added here dynamically -->
<!-- Loading indicator will be inserted here when needed -->
</div>
<div class="vf-chatbot-standalone__disclaimer vf-u-padding__right--400" data-vf-js-chatbot-standalone-disclaimer>
<div class="vf-banner vf-banner--alert vf-banner--info">
<div class="vf-banner__content">
<p class="vf-banner__text">Disclaimer: This chatbot is designed to assist you with general information and basic inquiries. See our <a class="vf-banner__link" href="https://www.ebi.ac.uk/data-protection/privacy-notice/embl-ebi-public-website/">disclaimer notes</a>.</p>
<button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>dismiss banner</title>
<path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
</svg>
</button>
</div>
</div>
</div>
</div>
<div class="vf-chatbot-standalone__input-container vf-u-padding__right--400">
<div class="vf-chatbot-standalone__input-wrapper">
<textarea class="vf-chatbot-standalone__input vf-form__textarea vf-u-padding__left--400" placeholder="Type your message..." rows="1" data-vf-js-chatbot-standalone-input></textarea>
<button class="vf-chatbot-standalone__send-button" aria-label="Send message" data-vf-js-chatbot-standalone-send>
<img src="../../assets/vf-chatbot/assets/vf-chatbot--icon-send.svg" alt="Send request">
</button>
</div>
<div class="vf-chatbot-standalone__footnote vf-u-margin__top--200" data-vf-js-chatbot-standalone-footnote>
Review AI generated content for accuracy. <a class='vf-link' href='https://embl.service-now.com/esc?id=sc_cat_item&sys_id=5eeb8eb91b92e650b376da88b04bcbc1'>Leave feedback</a>.
</div>
</div>
<template id="feedback-positive-template">
<div class="vf-chatbot-feedback__form vf-u-margin__top--400">
<div class="vf-chatbot-feedback__form-content vf-u-padding--400">
<div class="vf-chatbot-feedback__form-content-header">
<div class="vf-chatbot-feedback__title">Tell us more (optional)</div>
<button role="button" class="vf-chatbot-feedback__form-close vf-button vf-button--icon vf-button--dismiss | vf-banner__button" type="button" aria-label="Close feedback form" data-vf-js-feedback-form-close>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>dismiss banner</title>
<path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
</svg>
</button>
</div>
<div class="vf-chatbot-feedback__options">
<button class="vf-chatbot-feedback__option" data-feedback-option="accurate">
Accurate answer
</button>
<button class="vf-chatbot-feedback__option" data-feedback-option="easy">
Easy to understand
</button>
<button class="vf-chatbot-feedback__option" data-feedback-option="formatted">
Well formatted
</button>
<button class="vf-chatbot-feedback__option" data-feedback-option="helpful">
Helpful
</button>
</div>
<div class="vf-chatbot-feedback__comment-title">Comments</div>
<textarea class="vf-chatbot-feedback__comment" rows="4"></textarea>
<button type="submit" class="vf-chatbot-feedback__submit vf-u-padding--200" data-vf-js-feedback-submit>
Submit
</button>
</div>
</div>
</template>
<template id="feedback-negative-template">
<div class="vf-chatbot-feedback__form vf-u-margin__top--400">
<div class="vf-chatbot-feedback__form-content vf-u-padding--400">
<div class="vf-chatbot-feedback__form-content-header">
<div class="vf-chatbot-feedback__title">Tell us more (optional)</div>
<button role="button" class="vf-chatbot-feedback__form-close vf-button vf-button--icon vf-button--dismiss | vf-banner__button" type="button" aria-label="Close feedback form" data-vf-js-feedback-form-close>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>dismiss banner</title>
<path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
</svg>
</button>
</div>
<div class="vf-chatbot-feedback__options">
<button class="vf-chatbot-feedback__option" data-feedback-option="inaccurate">
Inaccurate answer
</button>
<button class="vf-chatbot-feedback__option" data-feedback-option="nocontext">
Did not use context
</button>
<button class="vf-chatbot-feedback__option" data-feedback-option="poorformat">
Poorly formatted
</button>
<button class="vf-chatbot-feedback__option" data-feedback-option="nothelpful">
Not helpful
</button>
</div>
<div class="vf-chatbot-feedback__comment-title">Comments</div>
<textarea class="vf-chatbot-feedback__comment" rows="4"></textarea>
<button type="submit" class="vf-chatbot-feedback__submit vf-u-padding--200" data-vf-js-feedback-submit>
Submit
</button>
</div>
</div>
</template>
<template id="user-message-template">
<div class="vf-chatbot-message vf-chatbot-message--user vf-u-margin__top--400">
<div class="vf-chatbot-message__avatar vf-u-margin__bottom--200">
<span class="vf-chatbot-message__avatar-name">You</span>
<img src="../../assets/vf-chatbot/assets/vf-chatbot--avatar-user.svg" alt="You">
</div>
<div class="vf-chatbot-message__content vf-u-padding--200">
<div class="vf-chatbot-message__content-prompt vf-u-padding__left--200 vf-u-padding__right--200">
Hello!
</div>
</div>
</div>
</template>
<template id="assistant-message-template">
<div class="vf-chatbot-message vf-chatbot-message--assistant vf-u-margin__top--400">
<div class="vf-chatbot-message__avatar vf-u-margin__bottom--200">
<img src="../../assets/vf-chatbot/assets/vf-chatbot--icon-16x16-dark-green.svg" alt="AI Assistant">
<span class="vf-chatbot-message__avatar-name">AI Assistant</span>
</div>
<div class="vf-chatbot-message__content vf-u-padding--200">
<div class="vf-chatbot-message__content-prompt vf-u-padding__left--200 vf-u-padding__right--200">
How can I help you?
</div>
</div>
</div>
<div class="vf-chatbot-feedback vf-u-margin__top--200" data-vf-js-chatbot-feedback></div>
</template>
<template id="loading-indicator-template">
<div class="vf-chatbot-message vf-chatbot-message--assistant vf-chatbot-message--loading vf-u-margin__top--400">
<div class="vf-chatbot-message__avatar vf-u-margin__bottom--200">
<img src="../../assets/vf-chatbot/assets/vf-chatbot--icon-16x16-dark-green.svg" alt="AI Assistant">
<span class="vf-chatbot-message__avatar-name">AI Assistant</span>
</div>
<div class="vf-chatbot-message__content vf-u-padding--200">
<div class="vf-chatbot-message__content-loading-dots">
...
</div>
</div>
</div>
</template>
<template id="action-prompts-template">
<div class="vf-chatbot-action-prompts">
<div class="vf-chatbot-action-prompts__list" data-vf-js-action-prompts-list>
<!-- Individual prompts will be populated here -->
</div>
</div>
</template>
<template id="single-action-prompt-template">
<div class="vf-chatbot-action-prompt">
<a href="#" class="vf-chatbot-action-prompt__link vf-u-padding--200">
</a>
</div>
</template>
</div>
</div>
File system location: components/vf-chatbot
Find an issue on this page? Propose a change or discuss it.