Refactor template response generation to allow us to add global context.