AI – Batch – Chatbot

email me

I created this simple batch file to demonstrate a learning bot. You will help build its knowledge base data in the file named speech.txt. Just copy the below code into a script like AI.cmd, and run it.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@echo off
set BotName=Chatty

title AI %BotName% 1.0 - Learner Bot
color 0b

rem Create the speech file if not exist
if not exist speech.txt echo.>speech.txt

Echo Start up a conversation with %BotName%
echo.

:START
set /p text="You: "

:: DYNAMIC QUESTIONS THAT PULL REALTIME INFORMATION
if /i "%text%"=="What time is it?" goto :TIME
if /i "%text%"=="What is the time?" goto :TIME
if /i "%text%"=="What is the date?" goto :DATE

:: OUR SPEECH FILE
for /f "tokens=1,* delims={" %%a in (speech.txt) do (

if /i "%text%"=="%%a" (
echo.
echo %BotName%: %%b
echo.
goto :START
)
)
echo.
echo %BotName%: I don't know what that means.
set /p answer=%BotName%: How should this be answered '%text%'?
echo %text%{%answer%>>speech.txt
echo %BotName%: Thanks!
echo.
goto :START
:TIME
echo.
echo %BotName%: The time is %TIME%
echo.
goto :START

:DATE
echo.
echo %BotName%: The date is %DATE%
echo.
goto :START