When you think of artificial intelligence (AI) companies, Salesforce (CRM -1.10%) likely doesn't come to the top of the list. However, it revealed several details about how it plans to integrate AI into its customer relationship management (CRM) software during its Q2 report.

So is Salesforce a top AI stock to buy right now? Or is it just capitalizing off of the buzz AI is generating? Let's find out.

AI has become a key product for Salesforce

Salesforce's CRM product is vital to maintaining customers and provides vital tasks like acquisition, support, and other external interactions. Its usage of AI is done through its Einstein offering, which can be integrated into several of its products.

With Einstein, clients can automate processes, create personalized marketing emails automatically, perform data analytics on its Tableau software, and improve customer support with Einstein Bots. The integration of AI into Salesforce's system is a natural one and will be used to boost productivity, freeing up employees to do what AI cannot.

Co-CEO and founder Marc Benioff talked about the "AI revolution" multiple times on the company's conference call, and didn't mince words when discussing the significance of AI with its platform.

This makes Salesforce one of my favorite types of AI investments, as the company will still survive regardless of how important AI becomes in a product offering. But Salesforce isn't just talking the talk; its Q2 results show it's performing quite well.

Salesforce's profitability is improving

In Q2 (ending July 31), Salesforce's revenue rose 11% year over year -- a respectable number considering that few companies are looking to spend significantly on enterprise software. But the most exciting piece of the report was its GAAP operating profit of 17%. While a common criticism of Salesforce was its lack of GAAP profitability despite its size, Salesforce has flipped that narrative on its head.

CRM Operating Margin (Quarterly) Chart

CRM Operating Margin (Quarterly) data by YCharts

As a result, Salesforce delivered strong earnings per share (EPS) of $1.28. Salesforce expects to continue this trend in Q3, when it expects about 11% growth and EPS to come in around $1.03.

These results are a testament to how strong of a company Salesforce is and its discipline when it's needed. But even the best companies bought at the wrong price can be disastrous investments. So, is Salesforce worth buying here?

The stock isn't that expensive compared to others

Although Salesforce has significantly improved its margins over the past year, it hasn't been consistent, which skews its price-to-earnings (P/E) ratio (it trades at 139 times earnings). But if you utilize forward projections (which account for improving margins), Salesforce trades at an attractive 27 times forward earnings. That makes the stock cheaper than Microsoft and Apple from a forward P/E perspective.

So with the concern of overpaying for the stock gone, I think Salesforce makes for an excellent buy right now despite being up nearly 70% this year. Obviously, it would have been better to invest in it at the start of 2023, but that's not feasible. So investors are left with the next best thing: right now.

With an improving economy allowing companies to spend more on enterprise software in 2024, Salesforce is well-positioned to continue its growth. Throw in AI integration, and Salesforce is a great stock to buy right now.