When I’m doing that kind of work, I tend to work in 1 hour blocks. Then I take a break, clear my head, check for significant comms, maybe rely to a couple, and then get back to my work. I have most notifications disabled so I don’t get that constant attention drain. This is all part of an effort to manage my time.
I even noticed that many co-workers added a third monitor just to have space for Slack being "up" all the time. I watched with interest as they would flick their heads to one side at any motion.
If your manager isn't willing to back you up on "My team needs to deliver X and that's my employee's job, if you want Y, we can try to schedule that in," find a job with a better manager. And if your manager says your job is answering questions about Y and not writing code for X, then, well, that is your job.
Haha, yes, my job is exactly like this. If I turn off Slack for an hour to write some code, I get a lot of angry emails from management about why I'm OoO without notice.
Co-workers love to complain to management if you don't respond to them immediately as well. One guy slacked me 6 times in the morning asking for help, I gave him a clear next step of adding a certain formatted section at the bottom of his spec for legal to review privacy concerns, then he never even did that work and Slacked me 13 more times that day which I ignored to get some work done, and management went ape shit.
Now I just double all my coding estimates because I know my real job is to be on Slack 8-5 answering questions.