How to inject custom message when streaming messages?

Hello,
I am building a chatbot in a web environment and, at some point, when a certain function is triggered by the assistant, I want to send a predefined message to the user, instead of the one generated by the chatbot. How can I do that when streaming is in place?

I have tried yield f"data: {whatever variable I have}" but it simply did not work. What shall I do?