Conditional formatting in Omnigraffle


I’m hoping to make a script which i can run on my diagrams to automatically colour shapes based on their text content. I’m new to scripting in omnigraffle and don’t really know where to start. I want something that iterates through the shapes looking for a substring in the text and setting the fill to a specific colour for any shapes which contain the string.

Has anyone made anything like this? It doesn’t seem like it should be super complex, but i just don’t know where to start…