News:

Welcome to RetroCoders Community

Main Menu

silly simple chatbot example

Started by ron77, Aug 15, 2023, 02:40 PM

Previous topic - Next topic

ron77

include std/console.e

procedure main()
    sequence user_input
    sequence response
    
    puts(1,"Hello! I'm your chatbot. Ask me something or say 'exit' to quit.")
    atom true = 1
    while true = 1 do
        printf(1, "\nYou: ")
        --gets(user_input)
        --user_input = user_input[1..length(user_input)-1]
        
        user_input = prompt_string("")
        
        if equal(user_input, "exit") then
            puts(1,"Chatbot: Goodbye!")
            true = 0
        elsif equal(user_input, "hello") then
            response = "Hi there!"
        elsif equal(user_input, "how are you") then
            response = "I'm just a program, but thanks for asking!"
        elsif equal(user_input, "what's your name") then
            response = "I'm ChatEuphoria, your friendly Euphoria chatbot!"
        else
            response = "I'm not sure how to respond to that."
        end if
        
        printf(1, "Chatbot: %s\n", {response})
    end while
end procedure

main()