help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
conversational-ai-bot
RSK World
conversational-ai-bot
Conversational AI Bot - Python + NLP + Flask + Machine Learning + Chatbot + AI
conversational-ai-bot
  • __pycache__
  • static
  • templates
  • .gitignore577 B
  • ADVANCED_FEATURES.md5.7 KB
  • CHANGELOG.md2.2 KB
  • INSTALLATION.md1.8 KB
  • LICENSE1.2 KB
  • PROJECT_INFO.md2.8 KB
  • PROJECT_STATUS.md3.4 KB
  • QUICKSTART.md2.5 KB
  • README.md4.8 KB
  • __init__.py448 B
  • api_integrations.py6 KB
  • app.py4.2 KB
  • chatbot.py14.8 KB
  • config.py1.1 KB
  • context_manager.py5.8 KB
  • conversation_analytics.py5.9 KB
  • conversation_history.json413 B
  • conversation_history.py4.9 KB
  • entity_extractor.py6.6 KB
  • example_usage.py4.3 KB
  • intent_recognizer.py6.6 KB
  • language_support.py5 KB
  • main.py4.7 KB
  • requirements.txt311 B
  • response_templates.py7.2 KB
  • sentiment_analyzer.py5.6 KB
  • setup.py1.6 KB
  • test_chatbot.py5 KB
  • validate_project.py4.1 KB
.env.exampleexample_usage.py
example_usage.py
Raw Download
Find: Go to:
"""
Example Usage of Conversational AI Bot
Demonstrates various features and capabilities of the chatbot.

Developer: RSK World
Website: https://rskworld.in
Email: help@rskworld.in
Phone: +91 93305 39277
Year: 2026
"""

from chatbot import ConversationalAIBot


def example_basic_conversation():
    """Example of basic conversation."""
    print("=" * 60)
    print("Example 1: Basic Conversation")
    print("=" * 60)
    
    bot = ConversationalAIBot()
    
    messages = [
        "Hello",
        "My name is John",
        "What's my name?",
        "What can you do?",
        "Thank you",
        "Goodbye"
    ]
    
    for message in messages:
        print(f"\nUser: {message}")
        response = bot.chat(message)
        print(f"Bot: {response}")
    
    print("\n")


def example_context_awareness():
    """Example demonstrating context awareness."""
    print("=" * 60)
    print("Example 2: Context Awareness")
    print("=" * 60)
    
    bot = ConversationalAIBot()
    
    # First conversation
    print("\nUser: My name is Alice")
    print(f"Bot: {bot.chat('My name is Alice')}")
    
    # Later in conversation, bot remembers
    print("\nUser: What's my name?")
    print(f"Bot: {bot.chat('What\'s my name?')}")
    
    # Context summary
    print(f"\nContext Summary: {bot.get_context_summary()}")
    print("\n")


def example_entity_extraction():
    """Example demonstrating entity extraction."""
    print("=" * 60)
    print("Example 3: Entity Extraction")
    print("=" * 60)
    
    bot = ConversationalAIBot()
    
    messages = [
        "My name is Sarah Johnson",
        "I live in New York",
        "My email is sarah@example.com",
        "Call me at +1-555-123-4567"
    ]
    
    for message in messages:
        print(f"\nUser: {message}")
        response = bot.chat(message)
        print(f"Bot: {response}")
    
    # Show extracted entities
    context = bot.context_manager.get_context()
    print(f"\nExtracted Entities: {context.get('entities', {})}")
    print("\n")


def example_multi_turn_dialogue():
    """Example of multi-turn dialogue."""
    print("=" * 60)
    print("Example 4: Multi-turn Dialogue")
    print("=" * 60)
    
    bot = ConversationalAIBot()
    
    conversation = [
        ("Hello, how are you?", "Greeting"),
        ("My name is Michael", "Name introduction"),
        ("What's my name?", "Name query"),
        ("What time is it?", "Time query"),
        ("What's the date?", "Date query"),
        ("Thank you for your help", "Compliment"),
        ("Goodbye", "Farewell")
    ]
    
    for message, intent_type in conversation:
        print(f"\nUser: {message}")
        response = bot.chat(message)
        print(f"Bot: {response}")
    
    print("\n")


def example_conversation_history():
    """Example showing conversation history."""
    print("=" * 60)
    print("Example 5: Conversation History")
    print("=" * 60)
    
    bot = ConversationalAIBot()
    
    # Have a conversation
    bot.chat("Hello")
    bot.chat("My name is David")
    bot.chat("What can you do?")
    
    # Retrieve history
    history = bot.get_conversation_history()
    
    print("\nConversation History:")
    for i, entry in enumerate(history, 1):
        print(f"\n{i}. User: {entry.get('user_message')}")
        print(f"   Bot: {entry.get('bot_response')}")
        print(f"   Intent: {entry.get('intent', 'N/A')}")
        if entry.get('entities'):
            print(f"   Entities: {entry.get('entities')}")
    
    print("\n")


def main():
    """Run all examples."""
    print("\n" + "=" * 60)
    print("Conversational AI Bot - Example Usage")
    print("Developer: RSK World (https://rskworld.in)")
    print("=" * 60 + "\n")
    
    examples = [
        example_basic_conversation,
        example_context_awareness,
        example_entity_extraction,
        example_multi_turn_dialogue,
        example_conversation_history
    ]
    
    for example_func in examples:
        try:
            example_func()
        except Exception as e:
            print(f"Error in {example_func.__name__}: {e}\n")
    
    print("=" * 60)
    print("All examples completed!")
    print("=" * 60 + "\n")


if __name__ == "__main__":
    main()

169 lines•4.3 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer