Upgrade motor or pump to a variable speed with Jandy AquaLink RS

We have a Jandy AquaLinkRS with a Hayward pump. I’d like to upgrade to a variable speed pump. Should we change the whole pump or motor and what will the Jandy support? This supports both our pool and attached hot tub that water falls into the pool.