You are doing that correct, what you need to add here is some sort of a middleware that takes that
question and generates an
answer for that. Since you have not shared any further information it is very difficult for us to answer. But, that will be something like this,
stream.Read(buffer, 0, buffer.Length);
string question = Encoding.Default.GetString(buffer);
var answer = Middleware.GenerateAnswer(question);
It can be anything, a simple class that takes input, processes it and generates some response. I can write that as,
public class Middleware {
public static string GenerateAnswer(string question) {
if(question == "How are you?") {
return "I am fine, what about you?";
}
}
}
Of course, this gets much complex with complex questions, and difficult slang-based statements, and that is where you need to discuss how to move ahead.
You can try out some libraries, if you'd like for NLP;
SyntaxNet | TensorFlow[
^]