In strong economic times, companies can devote significant resources to customer acquisition. But when a recession looks to be on the horizon, such aspirations can sometimes play second fiddle to just surviving.

And for companies like Twilio (TWLO 1.47%) that specialize in customer acquisition, the challenges can be especially acute. The San Francisco-based provider of communications tools has seen its revenue growth slow and its share price tank over the past year. 

So is Twilio a lost cause? Or could it be a great contrarian buy in anticipation of a turnaround? Let's find out.

Twilio's product isn't the problem

Twilio specializes in customer communications. While it got its start providing APIs (application program interfaces) for programming automatic text messages to be sent to clients, it has drastically expanded its offering to include a customer data program, customized emails, and two-factor authentication.

As a testament to Twilio's prowess, Gartner named Twilio a leader in the communication-platform-as-a-service (CPaaS) category, claiming the highest ability to execute.

But that hasn't saved Twilio from a rapid growth slowdown. In the second quarter , Twilio's revenue rose 10% compared to a 41% rise a year ago. This decline was caused by customers curtailing their product usage to cut costs. For a high-flying growth company like Twilio, that's unacceptable for a lot of investors. So, many moved on from Twilio stock. 

However, there was one silver lining in the quarter: how much Twilio beat expectations. Management only guided for 4% to 5% revenue growth for Q2 but clearly blew that out of the water. For Q3, management guided for 0% to 1% growth, and investors are hoping for the same result, but there are no promises.   

Even though Twilio is struggling right now, there are some catalysts on the horizon that could help boost its business. The company receives a business boost during election years as campaigns text information and email voters. Additionally, Twilio signed its largest-ever email deal in Q1 and its largest messaging deal in Q2, indicating customers are still choosing Twilio for their communication needs.

But there's another problem with Twilio's stock that investors will want to consider.

Losses are a large investment issue

Twilio's goal was to become a one-stop shop for all customer communication needs. It pursued this goal by making multiple acquisitions, but it came at the cost of deep losses. Now that growth is harder to come by, those losses are starting to be placed under the microscope.

As a result, Twilio went through a few rounds of layoffs, significantly decreasing its employee count. This drastically improved results -- Twilio shrunk its operating loss from $312 million to $142 million in Q2. But its current 14% loss margin (down from 33%) is still a long ways away from truly breaking even.

Because of Twilio's significant stock-based compensation expense of $153 million, it actually broke even from a non-GAAP perspective. This is critical as it turned Twilio into a positive-cash-flow business. But the dilution of Twilio's stock has been significant over the past five years.

TWLO Shares Outstanding Chart

TWLO Shares Outstanding data by YCharts

With Twilio's share count essentially doubling in five years, a single share bought in 2018 controls about half as much of the company as it used to earlier. This is the danger of stock-based compensation -- it's a tool that young businesses can use to attract top talent, but it can severely harm shareholders over the long term.

Twilio has a number of negatives, but there is another bright side: its valuation. The stock trades at a dirt cheap 2.6 times sales. At that level, it's as if the market doesn't expect Twilio to recover.

While I don't think the road ahead is easy for Twilio, its management has taken steps to improve profitability. When recession concerns lessen, Twilio should see a business resurgence, which could help it take the final step to achieve profitability.

With the stock now at around $60 per share, I think investors can easily take a small position in Twilio's stock with a turnaround play in mind. But the position size should be kept fairly minimal in case the turnaround doesn't happen.