Validating and controlling the flow of a conversation between end user and chatbot

Hey team,

I am trying to build a chatbot that can build a travel itinerary for the end user by asking a set of questions and getting their answers/preference on them. I need some guidance on the questions below on the best way to execute this task.

Context: My data about each destination (cities, things to see, weather, dates, etc.) is sitting in a SQL database. I need to ask around 15-20 questions all up and the flow + validity of these questions depends on the end user’s style of answering. Because of this I am planning on using a finite state machine model so that I don’t have to write multiple ‘else if’ conditions in just one block of code, so that I can always have a context master state that is used to understand which questions are already answered, and which question to go to next based on the end user’s last answer/preference.


  1. How can I use the OpenAI model to validate an answer given by the end user or should I be looking at an alternative for this (e.g. python library) due to cost and rate limit implications? E.g. the bot greets the end user and asks them if they would like to see a demo? Now the user could type yes, no, go ahead, yeah, okay, random text, etc. I want to be sure that the meaning was either Yes, No or Invalid. I tried using the completion model with curie by prompting it with the user’s answer and asking which one of the 3 options was it, but the results aren’t consistent. Should I try to use embeddings instead or am I going to hit my cost/rate limit ceiling pretty quick with this approach?

  2. Is using the finite state machine model the best way to control this type of conversation or would you recommend some other way? At the end of the day, I can’t think of any other way of doing this with the API other than writing a loop. Even if I fine-tuned a model with the questions, I’d still have to write the loop right?

  3. A lot of recommendations in similar community questions talks about using embeddings for searching data. But that data is generally paragraphs, Q&A, etc. My data is basically sitting in a db like I mentioned in the context. Is there a way to use embeddings to search this as well (multiple columns) or is the traditional sql search the best way?

Hope I have articulated my query well.