Getting Started with RCL
Section titled “Getting Started with RCL”Welcome to RCL (Rich Communication Language)! This guide will help you get started with creating conversational agents using RCL and its toolchain.
What is RCL?
Section titled “What is RCL?”RCL is a domain-specific language designed for creating Rich Communication Services (RCS) agents. It provides a declarative syntax for defining conversational flows, message types, and agent behaviors.
Quick Start
Section titled “Quick Start”1. Installation
Section titled “1. Installation”Using npm
Section titled “Using npm”# Install the CLI globallynpm install -g @rcs-lang/cli
# Or use npx (recommended)npx @rcs-lang/cli --versionUsing the Web IDE
Section titled “Using the Web IDE”Visit RCS Agent Studio for a browser-based development experience with no installation required.
2. Your First Agent
Section titled “2. Your First Agent”Create a file called hello-bot.rcl:
agent HelloBot displayName "Hello Bot" description "A simple greeting bot"
flow greeting start -> welcome
welcome: "Hello! I'm your friendly bot. How can I help you today?" "help" -> show_help "bye" -> goodbye * -> confused
show_help: "I can greet you and say goodbye. Try saying 'bye' when you're ready to leave." * -> welcome
goodbye: "Goodbye! Have a great day!" * -> end
confused: "I didn't quite understand that. Try saying 'help' for assistance." * -> welcome
messages Messages # Messages will be automatically generated from the flow3. Compile Your Agent
Section titled “3. Compile Your Agent”# Compile to JavaScript (for runtime execution)npx @rcs-lang/cli compile hello-bot.rcl
# Compile to specific formatnpx @rcs-lang/cli compile hello-bot.rcl --format javascriptnpx @rcs-lang/cli compile hello-bot.rcl --format json
# Generate a flow diagramnpx @rcs-lang/cli compile hello-bot.rcl --format d24. Test Your Agent
Section titled “4. Test Your Agent”# Validate syntax and semanticsnpx @rcs-lang/cli validate hello-bot.rcl
# Interactive testing (if available)npx @rcs-lang/cli test hello-bot.rclCore Concepts
Section titled “Core Concepts”Agents
Section titled “Agents”An agent is the top-level container for your conversational bot:
agent MyBot displayName "My Conversational Bot" description "Description of what the bot does" version "1.0.0"
# Agent configuration goes hereFlows define the conversation logic using states and transitions:
flow conversation start -> greeting
greeting: "Hello!" "hi" -> friendly_response "help" -> show_help * -> default_responseMessages
Section titled “Messages”Messages define what the bot says and how it's presented:
# Simple text messagestate: "Hello there!"
# Rich message with suggestionsstate: "What would you like to do?" suggestions ["Option A", "Option B", "Help"]
# Rich card messagestate: richCard "Welcome" medium title "Welcome to our service" description "How can we help you today?" media <image src="welcome.jpg" alt="Welcome">Context Variables
Section titled “Context Variables”Store and use information throughout the conversation:
flow ordering start -> get_name
get_name: "What's your name?" * -> get_order
get_order: "Hi {match}! What would you like to order?" context.customer_name = match * -> confirm_order
confirm_order: "Got it, {context.customer_name}! Your order is confirmed." * -> endPattern Matching
Section titled “Pattern Matching”RCL supports flexible pattern matching for user input:
state: "How can I help you?" "order *" -> take_order # Matches "order coffee", "order pizza", etc. "help" -> show_help # Exact match "cancel*" -> cancel_flow # Matches anything starting with "cancel" /\d+/ -> handle_number # Regular expression for numbers * -> default_handler # Catch-all patternDevelopment Workflow
Section titled “Development Workflow”1. Write RCL Code
Section titled “1. Write RCL Code”Start with a simple agent structure and gradually add complexity:
agent SimpleBot displayName "Simple Bot"
flow main start -> hello hello: "Hello!" * -> end
messages Messages2. Validate and Compile
Section titled “2. Validate and Compile”Always validate your code before deployment:
# Check for syntax and semantic errorsnpx @rcs-lang/cli validate my-bot.rcl
# Compile to your target formatnpx @rcs-lang/cli compile my-bot.rcl --format javascript3. Test Locally
Section titled “3. Test Locally”Test your agent logic before deployment:
const { ConversationalAgent } = require('@rcs-lang/csm');const agentDefinition = require('./my-bot.js');
const agent = new ConversationalAgent(agentDefinition);
async function test() { const response = await agent.processMessage({ type: 'text', content: 'hello' });
console.log('Bot response:', response.message);}
test();4. Deploy
Section titled “4. Deploy”Deploy your compiled agent to your preferred platform:
- Web applications (Express.js, React, etc.)
- Cloud functions (AWS Lambda, Google Cloud Functions)
- Mobile applications (React Native, Flutter)
- Chat platforms (Slack, Discord, Teams)
Best Practices
Section titled “Best Practices”1. Start Simple
Section titled “1. Start Simple”Begin with basic flows and add complexity gradually:
# Good: Simple, focused flowflow greeting start -> welcome welcome: "Hello! How can I help?" "help" -> show_help * -> end
# Avoid: Complex nested flows initially2. Use Clear State Names
Section titled “2. Use Clear State Names”Choose descriptive names for your states:
# Good: Descriptive namesflow ordering start -> welcome_customer welcome_customer -> take_drink_order take_drink_order -> confirm_order
# Avoid: Generic namesflow ordering start -> state1 state1 -> state2 state2 -> state33. Handle Edge Cases
Section titled “3. Handle Edge Cases”Always provide fallback responses:
state: "What size drink?" "small" -> confirm_small "medium" -> confirm_medium "large" -> confirm_large * -> ask_size_again # Handle unexpected input
ask_size_again: "I didn't catch that. Please choose small, medium, or large." * -> state # Try again4. Use Context Wisely
Section titled “4. Use Context Wisely”Store important information but don't over-complicate:
# Good: Store essential informationget_name: "What's your name?" * -> get_email context.customer_name = match
# Good: Use stored contextconfirm: "Thanks {context.customer_name}! Your order is confirmed."
# Avoid: Storing too much unnecessary data5. Organize Complex Agents
Section titled “5. Organize Complex Agents”For larger agents, consider breaking flows into logical sections:
agent CustomerService displayName "Customer Service Bot"
# Main entry flow flow main start -> identify_need identify_need: "How can I help you today?" "technical*" -> technical_support.start "billing*" -> billing_support.start "general*" -> general_support.start
# Specialized flows flow technical_support # Technical support logic
flow billing_support # Billing support logic
flow general_support # General support logicCommon Patterns
Section titled “Common Patterns”FAQ Bot
Section titled “FAQ Bot”agent FAQBot displayName "FAQ Bot"
flow faq start -> main_menu
main_menu: "What would you like to know about?" suggestions ["Hours", "Location", "Contact", "Services"] "hours" -> show_hours "location" -> show_location "contact" -> show_contact "services" -> show_services * -> main_menu
show_hours: "We're open Monday-Friday 9AM-5PM, Saturday 10AM-3PM." * -> main_menu
show_location: "We're located at 123 Main Street, Downtown." * -> main_menuOrder Taking Bot
Section titled “Order Taking Bot”agent OrderBot displayName "Order Taking Bot"
flow ordering start -> welcome
welcome: "Welcome! What would you like to order?" * -> process_order
process_order: "Great choice! What size?" context.item = match "small" -> confirm_order(size="small") "medium" -> confirm_order(size="medium") "large" -> confirm_order(size="large") * -> ask_size_again
confirm_order: "Perfect! One {context.size} {context.item}. Anything else?" "no" -> finalize_order "yes" -> welcome * -> finalize_orderNext Steps
Section titled “Next Steps”- Explore Examples: Check out examples/ for more complex agent implementations
- Read the API Documentation: Learn about the full API
- Join the Community: Get help and share your agents
- Contribute: Help improve RCL by contributing to the project
Getting Help
Section titled “Getting Help”- Documentation: Browse the main documentation
- Examples: See examples/ for real-world use cases
- Issues: Report bugs or request features on GitHub
- Community: Join our Discord server for discussions
Happy bot building! 🤖