There are many different ways. You could start out simple and have a function for each npc, every time you press enter, it adds to a variable which acts as a counter and then sets a different bit of text. So whatever you did so far to start and show the conversation you show different text through sub events against variable conditions and when you want to end you just add the actions to close the chat etc on the final sub event.
You can also store chat in an array. You can set this up in an array file then load it into an array and read from it. Each npc would have a variable that relates to a column of the array and when you chat it runs through each row of that column.