Refactor, begin to separate api from chatbot