RetroCoders Community

Other Languages Programming => Euphoria => Topic started by: ron77 on Aug 15, 2023, 02:40 PM

Title: silly simple chatbot example
Post by: ron77 on Aug 15, 2023, 02:40 PM
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()