Propelled by the era of big data, intelligent question-answering systems have found widespread applications across various domains, offering users a means to swiftly and efficiently acquire answers. Compared to traditional methods of collecting textual knowledge and utilizing web search engines, these systems demonstrate distinct advantages. With the rapid evolution of knowledge graph technology, intelligent question-answering systems have entered a new stage of development. In response to the call for smart agriculture, this study has undertaken the construction of a knowledge-based question-answering system based on knowledge graphs, aiming to provide users with question-answering services related to crop diseases and pests. The primary tasks include: (1) Acquisition of crop disease and pest data: Employing a distributed web crawling framework to retrieve data from web pages related to crop diseases and pests and preprocessing operations involve data cleaning, analysis, and structuring. (2) Construction of knowledge graph: Following data analysis, defining entity and relationship categories for the knowledge ontology and completing the pattern layer construction of the knowledge graph. Utilizing rule-based triple templates for extracting entities from semi-structured text, building the data layer, and storing triples in the Neo4j graph database. (3) Design of question-answering algorithms: Employing the BERT-BiLSTM-CRF model for question entity recognition and the BERT-RNN model for question classification. Matching templates, executing queries through Cypher statements, and processing answers into natural language forms for return. (4) Implementation and visualization of the question-answering system: Integrating crop disease and pest knowledge graphs with question-answering algorithms, the Flask framework and various web technologies are used to implement functionalities such as user questioning, entity recognition, knowledge retrieval, and answer presentation. Experimental results indicate that the entity recognition and question classification models achieved Precision (P), Recall (R), and F1 scores of 93.22%, 92.69%, 92.21%, and 94.37%, 93.92%, 92.66%, respectively. Compared to other search methods, the question-answering system demonstrated higher accuracy and stability. This study provides an intelligent solution for agricultural informationization, offering a new pathway for users to acquire knowledge on crop diseases and pests.