faq_db = { "hi": "hello. how may I help you", "what are your opening hours": "Our support team is available 24/7 to assist you.", "how can i reset my password": "To reset your password, click on 'Forgot Password' on the login page.", # ... more FAQs here}
Matches the normalized user input against the FAQ database.
Copy
def get_response(user_input): normalized = user_input.strip().lower() for question, answer in faq_db.items(): if question in normalized: return answer return "I'm sorry, I didn't understand that. Could you please rephrase?"
def main(): print("Welcome to Multilingual Support Chatbot!") source_lang = input("Enter your language code (e.g., 'yo' for Yoruba, 'ig' for Igbo): ") while True: user_input = input("You: ") if user_input.lower() in ["exit", "quit"]: print("Goodbye!") break # Translate to English for matching input_en = translate(user_input, source_lang, "en") # Get English response response_en = get_response(input_en) # Translate back to user's language response_user_lang = translate(response_en, "en", source_lang) print(f"Bot: {response_user_lang}")if __name__ == "__main__": main()
Welcome to Multilingual Support Chatbot!Enter your language code (e.g., 'yo' for Yoruba, 'ig' for Igbo): yoYou: Bawo ni mo se le tun oro igbaniwo mi seBot: lati tun oro igbaniwo re se, tẹ lori 'gbagbe oro igbaniwo' lori oju-iwe wiwọle ati tẹle awọn ilana naa.