This works on third-party, non-Kontakt MIDI keyboards or controllers, and Kontakt controllers, obviously.
Download Kontakt Komplete Control, and install on your computer. Launch it.
Go to Preferences and identify and choose your MIDI controller. It should be showing on a list, even if it wasn't made by Native Instruments.
Load Massive X and select (double click) a patch.
Click the MIDI box near the upper right of the interface.
Then you should see a screen showing the macro settings. Click on each macro and wiggle your controller slider or knob. Your slider or knob should now be mapped to that macro after you click the MIDI box again to close the function.
This info is not in the Massive X manual. This has confused many users, including me.