Skip to main content
This example demonstrates how to build a chatbot assistant with input/output moderation, topical rails, and conversational flows using NeMo Guardrails.

Overview

The ABC Bot is an employee assistance chatbot that:
  • Answers questions about company policies and employee handbook
  • Implements input validation and output moderation
  • Enforces topical boundaries to stay on topic
  • Refuses to respond to inappropriate or off-topic queries

Complete Configuration

1

Define general instructions and sample conversation

2

Create topical rails to refuse off-topic requests

Define what topics the bot should refuse to discuss.
3

Add knowledge base

Create a knowledge base with your company documentation:
kb/employee-handbook.md

Usage Examples

Conversation Examples

1

Normal conversation

2

Off-topic rejection

3

Harmful content rejection

Guardrails Active in This Example

  1. Input Validation - Uses self check input to validate user messages before processing
  2. Output Moderation - Uses self check output to ensure bot responses are appropriate
  3. Topical Rails - Dialog flows that prevent discussing off-topic or harmful subjects
  4. Knowledge Base Integration - Retrieves information from company documentation

Colang 2.x Version

For the modern Colang 2.x syntax:

Testing

Run the chatbot using the CLI:
Try these test queries:
  • “Hi!” - Should greet appropriately
  • “What are the company benefits?” - Should provide information
  • “How do I cook rice?” - Should refuse politely
  • “Teach me bad words” - Should refuse firmly