📘 Lesson  ·  Lesson 93

Simple Chatbot

इस Project के बारे में

💡 एक नज़र में

एक simple rule-based chatbot जो user के message के keywords के आधार पर जवाब देता है।

Program

Python
def chatbot(message):
    msg = message.lower()
    if "hello" in msg or "hi" in msg:
        return "Hello! How can I help you?"
    elif "name" in msg:
        return "I am CodeBot, your assistant."
    elif "bye" in msg:
        return "Goodbye! Have a nice day."
    else:
        return "Sorry, I did not understand that."

print(chatbot("Hi there"))
print(chatbot("What is your name?"))
print(chatbot("bye"))
Hello! How can I help you? I am CodeBot, your assistant. Goodbye! Have a nice day.

सारांश

  • Bot message में keywords जाँचकर matching reply लौटाता है।
  • असली chatbots NLP/ML use करते हैं, पर यह core idea दिखाता है।
← Back to Python Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

💻 लाइव कोड एडिटर

इस पेज के प्रोग्राम यहीं तैयार हैं — चलाएँ, बदलें और सीखें। कुछ भी इंस्टॉल किए बिना।
OneCompiler द्वारा संचालित। कोड एडिटर में अपने आप आ जाता है — Run दबाकर आउटपुट देखें। अगर एडिटर न खुले तो नए टैब में खोलें.