Here's a picture!
Making the chatbot itself is not so hard, here's some of the code:
question = txtInput.Text.ToLower.TrimListBox1.Items.Add("User: " & question)
If question.IndexOf("what's the time") > -1 ThenTellTime()End If
Private Sub TellTime()
ListBox1.Items.Add(("Chatbot: the time is: ") & System.DateTime.Now.ToString("HH:mm:ss"))
synth.Speak(("the time is: ") & System.DateTime.Now.ToString("HH:mm:ss"))
End Sub
I'm gonna just take a line or two at a time.
question = txtInput.Text.To.Lower.Trim
This line takes the text in txtInput and puts it in the variable question in lower case and with no double spaces.
Listbox1.Items.Add("User: " & question)
Writes the users question in the Listbox1.
If question.IndexOf("what's the time") > -1 Then
TellTime()
End If
Checks if the variable question contains the sentence "what's the time", and if it does, then it opens the Sub routine TellTime()
ListBox1.Items.Add(("Chatbot: the time is: ") & System.DateTime.Now.ToString("HH:mm:ss"))
Adds the Chatbots answer to the listbox, System.DateTime.Now.ToString("HH:mm:ss") is the time to show the time.
synth.Speak(("the time is: ") & System.DateTime.Now.ToString("HH:mm:ss"))
This makes the Chatbot actually speak, however this requires you to add a reference, i'll make a post about it later.
Here's another picture!
This picture shows how the Google search works, if you want to search as I'm feeling lucky all you have to do, is instead of writing "tell me all about" then just type "tell me about", and it'll do a i'm feeling lucky search.
That's all i have for you this time.
-Rasmus Iversen


No comments:
Post a Comment