This feature is a courtesy of the new iOS 11 operating system, whereby it enables third party applications to filter incoming messages and sort them into a separate SMS Junk tab that appears in the Messages app when you use an app that lets you filter messages just like the new version of Truecaller.
These type of apps can use keyword detection or machine learning algorithms to figure out if the messages you are receiving contained spam or useful and then sort them accordingly.
Once you update the app, it will guide you on how to enable it.
Just go to Settings > Messages > Unknown & Spam > turn on Truecaller. I’m not quite sure if Truecaller uses simply keyword filtering or machine learning to determine if an incoming message contains spam or not.