Ensuring the chatbot replies correctly to web visitors is controlled with the chatbot's confidence level threshold. You can decide how sure the chatbot has to be about its reply in order to make that reply. If you set the the threshold to 100%, the chatbot keeps the conversation going only if it is absolutely certain that its reply is correct. If the confidence level falls below your threshold, the chatbot invites a customer service agent into the conversation.
The capability to self-analyse the confidence level is built in the modern chatbots. The knowledge comes from the training material the chatbot has received prior to the current conversation. When the chatbot is first implemented, historical chat logs and FAQs can be used as training material. Once the chatbot is in use, it keeps on learning by analysing the conversations of customer service agents and visitors.