Lua - Receive Midi

I’m currently using Electra to control various functions of Logic Pro X

Am using Pitchbend to map to fader volume using a suggestion from this thread

This works but I want to sync feedback from Logic to electra so when switching channels the virtual control on electra is set to the correct value

Using Lua - what do I need to look at to interrogate incoming MIDI messages ? Do I then update the Parameter map with my value or do I update the control directly (does updating the parameter map automatically update the control ?)