Receiving custom mavlink message on onboard computer

Hello, we have telemetry modules connected to pixhawk and ground control computer, this way we transfer and receive mavlink messages. What we want to achieve is to be able to send custom mavlink messages from ground computer via pymavlink (which includes a json string payload) and receive this from the companion computer via pymavlink. I also want to send mavlink messages from companion computer to ground computer. The reason I want to do this is to perform autonomus actions. How can i do that?
(I regenerated pymavlink to add my own custom message, do i somehow need to flash a new ardupilot software to pixhawk to get my custom message recognized by ardupilot? also how can i route the message to pixhawk after i receive it on pixhawk?)