Emotions are part of human mental activities and play an extremely important role in the decision-making process of daily life. Publishing posts in natural language through social websites is part of people’s lives. These posts can reflect the emotion state of users. It is important to study how to use machine learning technology to interpret the sentiment analysis of posts. The research proposed a general framework based on sentiment analysis and machine learning, called Sentiment Analysis and Machine Learning Recommendation Framework (SAMLRF), including data preparation module, sentiment analysis module, recommendation module, human machine module and cloud computing module for a chatbot to facilitate user interaction to make recommendations. To verify the modular function of the proposed SAMLRF, this research develops a Sentiment-based Article Recommendation Linebot (SARL), which provides an API interface for chatbots to activate the system through a webhook mechanism. The performance and accuracy of four machine learning and two deep learning algorithms were compared, including the decision tree, logistic regression, support vector machine and gradient boosting decision tree, simple recurrent neural networks and long short-term memory, operating in Spark cloud computing environments. Experiments show that the decision tree algorithm for sentiment analysis is relatively better in computing performance and test accuracy.