Origin of ChatBots
Historically, the first chatbot was ELIZA. This system was built in 1966 by Joseph Weizenbaum to simulate a psychotherapist (Weizenbaum, 1996).
“The fundamental technical problems with which ELIZA is concerned are: (1) the identification of key words, (2) the discovery of minimal context, (3) the choice of appropriate transformations, (4) generation of responses in the absence of key words, and (5) the provision of an editing capability for ELIZA "scripts". ( Weizenbaum, 1996)
“The text is read and inspected for the presence of a keyword. If such a word is found, the sentence is transformed according to the rule associated with the keyword, if not a content free remark or, under certain conditions an earlier transformation is retrieved.” (Weizenbaum, 1996)
Reference
Weizenbaum, J. (1966). ELIZA - a computer program for the study of natural language communication between man and machine. Commun. ACM, 9, 36-45.
For more information on ELIZA and the coding behind it, try this article:
http://web.stanford.edu/class/cs124/p36-weizenabaum.pdf
For information on ALICE, try this article.
https://en.wikipedia.org/wiki/Artificial_Linguistic_Internet_Computer_Entity