Suggestion. I think the cleanest way to do this would be to extract a method (used by both sendRequest and sendResponse) that returns a Either[Throwable, Message]

Then instead of for(res <- optResponse) you can do
generate(message) match {
case Left(t) => handle failure case
case Right(m) => send message
}