Yes, the Intelligent Network was the big thing in the 1990s. It allowed for routing as you describe as well as calling cards and many other features:
https://en.m.wikipedia.org/wiki/Intelligent_Network
We’ve had techs come to our home in Canada in the 1990s, and I remember being fascinated with their mystical toolbox phone that seemed to uncover hidden phone line functionality. Almost like the whip in Indiana Jones.