I'm trying to represent a conversation as a series of decisions for a chatbot I'm building. I'm not sure if a tree is the best data structure of this, but it was the first that came to mind.
For example, the chatbot may ask the user "How are you?", to which the user might respond positively or negatively. If the user responds positively, I want the chatbot to traverse the tree in that direction where the next node would be the set of possible responses to a positive answer (and vice versa).
Is this the right way to represent a conversation like this? If so, what is the best way to implement it?
I think it's difficult.Your way is too simple to reach your demand.
First, how do you judge the answer that users respond is positive or negative?
How about the user answering "Who are you?"
If the answer users respond is also simple ,it might work.Just search in the tree to find the answer to the user's repond.
Maybe you can learn some Artificial Intelligence method to do it.
Tree Data Structure for Conversation