Due to the increasing global population and the growing demand for food worldwide as well as changes in weather conditions and the availability of water, artificial intelligence (AI) such as expert systems, natural language processing, speech recognition, and machine vision have changed not only the quantity but also the quality of work in the agricultural sector. Researchers and scientists are now moving toward the utilization of new IoT technologies in smart farming to help farmers use AI technology in the development of improved seeds, crop protection, and fertilizers. This will improve farmers' profitability and the overall economy of the country. AI is emerging in three major categories in agriculture, namely soil and crop monitoring, predictive analytics, and agricultural robotics. In this regard, farmers are increasingly adopting the use of sensors and soil sampling to gather data to be used by farm management systems for further investigations and analyses. This article contributes to the field by surveying AI applications in the agricultural sector. It starts with background information on AI, including a discussion of all AI methods utilized in the agricultural industry, such as machine learning, the IoT, expert systems, image processing, and computer vision. A comprehensive literature review is then provided, addressing how researchers have utilized AI applications effectively in data collection using sensors, smart robots, and monitoring systems for crops and irrigation leakage. It is also shown that while utilizing AI applications, quality, productivity, and sustainability are maintained. Finally, we explore the benefits and challenges of AI applications together with a comparison and discussion of several AI methodologies applied in smart farming, such as machine learning, expert systems, and image processing.