Here is a part of my current (working) chatbot code in Notepad so you can get an idea of how I am coding it:

dim n, q

n=inputbox("Hello, I'm a chatbot. What is your name?")
q=inputbox(""& n &" is a great name! Thank you for activating me, "& n &"! How are you?")

I want to be able to make "if and else" parts (for example, if "happy" is typed in after being asked "How are you feeling" it should say "great", if you type anything else it would say something differently.) How do I do this in Notepad?

Also, how do I get it to loop and say something based on keywords (like how Eliza the chatbot will keep talking for infinity just by looping and referring to a bank of keywords and responses) in Notepad?

I know these are really basic questions, but I have have searched the web multiple times; all searches ending up empty handed.

有帮助吗?

解决方案

Unfortunately, you asked a very inspecific question making it hard to answer. That is why your post received a downvote and a close down request. However, you seem enthousiastic and I can only encourage that.

First of all, VBScript is not a very nice language. Oh, yes it seems simple, it nicely integrates with some standard windows components and you can run it out of the box. But it is ancient and does some things differently than more common languages. If you want to do more complex things faster, ultimately you'd switch to another (scripting) language.

With VBScript it is not (easily) possible to use notepad as input/output device. For your setup I'd prefer the command line (press your windows key and enter CMD+enter, there it is). You can write output to the command line with

WScript.StdOut.Write "What is your name?"

You can retrieve output from the command line with

wscript.stdin.read(0)
name = wscript.stdIn.readline()

And to make your chatbot complete:

WScript.StdOut.Write "Hello " & name

Now you want to do some conditional branching. Well, I do not say W3Schools is a very good resource, but for now it is sufficient. Look at their if ... then ... else page (<- clickable link). If you are using IE, you can even try some things yourself.

Finally you can use Do While ... Loop's to make the code repeat itself.

A chatbot like Eliza is a prestigeous project. Don't be discouraged if you only can build a very simple version. The cake is in the coding, not the result.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top