Arduino Mega send data to ESP8266-01 then ESP forward to RPI (MQTT)

That's what I've been trying to get help with. How to write a code that will pass the info? What command tell the Mega to send the data to the ESP and what tells the ESP to send the data that it received?