Hi IF,
I think this is what you want. You were right about the issue -- you were consing onto the history list but then immediately throwing away the result because it wasn't modifying the original history value.
#lang racket
(struct message (str sender recipient) #:transparent)
; This returns a list consisting of the message that we are sending
; out; followed by the message that the participant posted. It will
; be appended; to the history.
(define (say m str)
(displayln str)
(list (message str "me" "participant") m))
; start off with an empty history
(let loop ([history '()])
(display "Chatbot: ")
(loop
(append
(match (message-str input)
[(regexp #rx"(?i:Hello,* world!)")
(say input "I would not know about the rest of the world, but I can hear \
you just fine.")]
[(regexp #px"(?i:I( am|'m) learning how to program in Racket,* world!)")
(say input "Racket is a great language, and it is lovely that you are \
learning it, but does literally everyone need to know?")]
[(regexp #px".*,+\\s*world!")
(say input "Did the whole world really need to hear that?")]
; if your input is DEBUG then it will print out the history but not add to it
["DEBUG" (pretty-print history) '()]
; if you type something unrecognized it will say so
[else (say input "I didn't understand that")])
history))
(loop))
PS Do I have the salutation right? Is it 'Hello, IF' or 'Hello, Karona'?