Here is the simplest way I have seen to use invocable methods to send data from flow to apex and apex to flow. This is a huge improvement over what I wrote in 2021.
The trickiest thing to understand here is that an output variable in Flow is an INPUT variable in Apex. It goes OUT from the Flow and IN to your Apex. I have some charts to help clarify what goes in and what comes out.
Some caveats: These are not examples of when to use Flow and Apex together, but just how it can be done. Also, I am a newer developer and I am just figuring this stuff out. If you see ways to improve, let me know!
Thanks to @jonsayer for showing me this method while working on the latest Unsubscribe Link (coming soon)!
EXAMPLE ONE
Get an Account Id, send it as a text variable from the Flow to Apex, return all the opportunities on that account to the flow, and update them in the Flow.
