From the Super Mario Wiki, the Mario encyclopedia
The bird plays a role in Chapter 4 of the game, where Mario with Vivian must know Doopliss's name in order to regain his body. He heads back to Creepy Steeple, where Doopliss lives. Going to the bottom of a well, Mario and Vivian manage to find a secret passage to a hidden room. Inside, they find the parrot; at first, the Parrot feigns ignorance simply saying random things such as wanting crackers, or even a phrase about getting a Shine Sprite, referencing Super Mario Sunshine. But if Mario uses Vivian's Veil ability, the parrot will speak. At first, the Parrot only complains about his predicament of being locked in a room, but after some ranting, it finally yells out the name of its captor, Doopliss. After hearing this, Mario and Vivian spring from the shadows, and leave the room. They have to take the letter "p" in the room to spell Doopliss's name, however.
After Doopliss abandons Creepy Steeple, he leaves the Parrot in his room. If Mario and his partners visit the Parrot after Chapter 4, it will speak to the player normally (complaining about Doopliss leaving him there alone), and nothing will happen if the player uses Veil in the room.