Building a Chat Bot

Clearing out some old projects from years ago, I came across a console app that uses AIML bot, an open source project to build a simple chat bot based on configurable text templates to match user input with (hopefully) meaningful, if not Turing-like, responses.

chat bot

The project needs the AIMLBot.dll and the aiml (subject matter markup) and config (settings and word substitutions) folders shipped with the AIMLBot binary.



Bot chatBot = new Bot();
chatBot.loadSettings();

User consoleUser = new User("consoleUser", chatBot);

chatBot.isAcceptingUserInput = false;
chatBot.loadAIMLFromFiles();
chatBot.isAcceptingUserInput = true;

while (true)
{
	Console.ForegroundColor = ConsoleColor.Green;
	Console.Write("> ");
	string typedInput = Console.ReadLine();

	if (typedInput.ToLower() == "quit")
		return;

	Result botResponse = chatBot.Chat(new Request(typedInput, consoleUser, chatBot));
	Console.ForegroundColor = ConsoleColor.Red;
	Console.WriteLine(botResponse.Output);
}