The overall market has been bearish since the start of the year, but several top tech stocks began feeling this bearish pressure more than a year ago. Whenever the sell-off began, many of these once-loved stocks with such hopeful futures were relentlessly sold off and regularly trade at or near 52-week lows.

But these grim numbers also present a potential investment opportunity for some of these stocks, including tech stocks Twilio (TWLO 0.19%) and Palantir (PLTR -0.77%). Both companies continue to post strong earnings, making for quite reasonable valuations. Because the long-term opportunities for these two tech stocks are significant, investors might want to consider them before they begin their next bull run.

1. Twilio

Twilio's business focuses on everything related to customer communication. Its primary product helps companies communicate with customers via text messages, providing services like confirming an appointment or providing automated delivery updates. Twilio also has products that seamlessly set up video appointments, deliver tailored marketing emails, and process customer data to drive better engagement.

These solutions may sound useful, but they also sound tech-heavy, placing such tools out of the reach of businesses without significant technical resources. And that's where Twilio shines -- all the programming is done using APIs (application program interfaces), which allow users with no coding experience to simply plug and play its products. It even has an educational online computer game, TwilioQuest, which gives businesses all the building blocks necessary to code effectively.

With more than 275,000 active business accounts, Twilio's products have reached a broad audience. Additionally, these businesses spend more each year on Twilio services, with the average active account spending $123 in Q2 for every $100 spent last year. This expansion is primarily due to Twilio's pay-as-you-go model, which only charges customers based on how often its APIs are used (there are volume and committed-use discounts available).

Overall, Twilio's organic revenue (which excludes acquisitions made over the past 12 months) was up 33% year over year in Q2 to $862 million. CEO and co-founder Jeff Lawson sees more of the same over the next few years, as he expects 30% or greater organic revenue growth through 2024. Additionally, he expects non-GAAP operating profits starting with full-year 2023 results, and recently laid off 11% of Twilio's workforce to expedite this goal.

Both the business idea and execution are investible, but Twilio's valuation makes it a candidate for a bull run. At four times sales, it is valued like a company that has no growth left. This valuation doesn't match up with the CEO's expectations and is not reflective of Twilio's current business execution.

With all three aspects of Twilio looking attractive, it's a no-brainer buy with the stock market down.

2. Palantir

In today's digital society, a lot of data is generated. Some of it is useful, but most of it is just noise. Sifting through this data manually isn't feasible, and deriving actionable insights would be even more difficult. That's where Palantir comes in. Palantir's data platform intakes all of a business's data and evaluates it automatically. Ways it can be used include pinpointing supply chain weaknesses or maximizing energy efficiency.

Those use cases are mainly for businesses, but Palantir started as government-focused software. Palantir's software is used by all of the main U.S. government agencies, including the FBI, CIA, and Department of Defense (DOD). In fact, the DOD just signed a one-year contract worth $229 million to improve its artificial intelligence and machine learning capabilities to recognize images better. Palantir also provides technology to some foreign governments like the U.K., further broadening its market.

As Palantir moves into its next business stage, where both governments and civilian companies use its data-processing platform, investors need to understand that Palantir's contracts tend to be massive and clunky. The $229 million, one-year contract mentioned above is an example of massive, as Palantir's trailing-12-month revenue is currently $1.74 billion.

Even its civilian contracts are enormous. Palantir only has 304 customers, meaning the average customer spends about $5.7 million annually with Palantir, with the top 20 commercial customers spending an average of $46 million. Despite its expensive price, the customer base is rapidly rising -- it grew 80% year over year in Q2.

Palantir could see some short-term headwinds, as businesses are reluctant to sign multi-million dollar deals as the economy sours. One entity that won't feel this effect as much is the U.S. government, whose spending grew 45% year over year to $290 million in Q2.

With Palantir trading at 9.4 times sales, investors are valuing it like it will have a difficult few years due to the economic environment. While this may be partially true on the commercial side, it is far from the truth for government contracts.

With operating losses shrinking, a consistent customer in the U.S. government, and an incredibly powerful software platform, Palantir makes for a great candidate to be bought during this bear market.