If I go the custom module way, how can I trigger a specific function in the custom module with the widget
Triggering something with a widget is a user interaction, there should be no problem sending messages from scripts executed that way.
The usual way to trigger something in the custom module with a widget is to send an osc message, and catch it in the custom module's oscOutFilter function.
and will it be available for every widget ?
No, the custom module will just be able to filter incoming/outgoing messages, it can only communicates with the client app using osc messages