For years, several countries have been concerned about how to dispose of unused pharmaceuticals that can endanger human health and the environment. Moreover, some people are in desperate need of medical attention and medications, but they lack the financial resources to obtain them. In Saudi Arabia, there are no take-back medicine programs, and there is no published research on how medications properly are disposed. The aim of this research is to use the power of artificial intelligence to assist in the proper management and disposal of expired and unused medications and to develop a prototype device for collecting medication by automatically classifying medications for proper disposal and donation. In this research, artificial intelligence technologies such as web-based expert systems, image recognition and classification algorithms, chatbots, and the internet of things are used to assist in a take-back medications program. In conclusion, the prototype design of a web-based expert system and the device reduced improper disposal risks by providing significant advice on the safe disposal of unwanted pharmaceuticals. By using an organized method of collecting expired medications, the benefits were made possible.