Last year, Google rolled out Smart Compose and autocorrect to Gmail and the G Suite version of Google Docs. The feature automatically suggests words based on your writing patterns and common phrases, and it's eerily good at it. It looks like Google wants to expand Smart Compose to more apps, as 9to5Google has discovered a test that brings the feature to Gboard. As far as we can see, it works in multiple messengers like Google Messages, WhatsApp, and Telegram, but it may also be available for other apps.
Smart Compose is part of a server-side A/B test available in the latest Gboard beta, version 22.214.171.1247844448. So far, it has only rolled out to a few people, and there's apparently no way to enable it manually. If you're one of the lucky few, you'll see an explanation on how to use the feature when it's first activated. Like in Gmail, you can swipe right on the suggested text to enter it. It's unclear how exactly Gboard manages to integrate so tightly with third-party apps. Since everything happens inside text-entry fields, it's possible that chat apps themselves don't have to add any code to make it work.
While the feature is only rolling out to a limited set of random testers, you can try your luck by signing up for the Gboard beta on the Play Store or by getting it from APK Mirror. You might also need a recent version of the Play Services — try the beta version here, too, but note that your mileage may vary.