Segments allow you to adapt the chatbot’s responses based on the page context.
Concept
A segment is a specific context. For example:
- Home page → segment
landing
- Pricing page → segment
pricing
- Support page → segment
support
The chatbot only uses the corpus associated with the active segment.
Usage
Via HTML
<!-- Home page -->
<script
src="https://animam.ai/widget.js"
data-tenant="your-slug"
data-segment="landing"
></script>
<!-- Pricing page -->
<script
src="https://animam.ai/widget.js"
data-tenant="your-slug"
data-segment="pricing"
></script>
Via JavaScript
// Change segment dynamically
window.Animam.setSegment("checkout")
Useful for SPAs (Single Page Applications) where the segment changes without page reload.
Dashboard configuration
- Go to Dashboard > Knowledge Base
- For each entry, assign one or more segments
- Entries without a segment are available everywhere
Concrete example
E-commerce scenario
| Segment | Corpus | Example question |
|---|
landing | Product presentation | ”What is your product?” |
pricing | Pricing, subscriptions | ”What’s the price?” |
checkout | Payment, shipping | ”What payment methods?” |
support | Technical FAQ | ”How do I reset my password?” |
Implementation
<!-- pages/index.html -->
<script src="https://animam.ai/widget.js" data-tenant="shop" data-segment="landing"></script>
<!-- pages/pricing.html -->
<script src="https://animam.ai/widget.js" data-tenant="shop" data-segment="pricing"></script>
<!-- pages/checkout.html -->
<script src="https://animam.ai/widget.js" data-tenant="shop" data-segment="checkout"></script>
Default segment
If no segment is specified, the chatbot uses:
- Entries from the
default segment
- Entries without an assigned segment
Best practices
Create a global segment for general questions (hours, contact, about) available on all pages.
- Limit the number of segments (5-10 max)
- Name them clearly (
pricing not seg_01)
- Test each segment individually