'Search for People Chips in a Google Doc and Replace it

I'm trying to create a script to find and replace every Person chip in a google doc with their handle on a different platform.

My original thought was to create a Google Sheet with the chip and the corresponding handle and cycle through that, but having a hard time figuring out how to parse through the google doc and find the related chip to begin with.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source