Accessing sdk.config from outside hooks and actions

In hooks and actions, we receive the bp object of type typof sdk, and we can use its functions, e.g bp.config.getModuleConfigForBot.

However, using import * as bp from 'botpress/sdk' we can not do the same in a regular module as there is no config property on the imported object. Logging the object reveals only

{ sdk:                                                                                                                                                                                                                                          { version: '12.8.6',
     LoggerLevel:
      { Info: 'info',
        Warn: 'warn',
        Error: 'error',
        Critical: 'critical',
        Debug: 'debug' },
     LogLevel:
      { '0': 'PRODUCTION',
        '1': 'DEV',
        '2': 'DEBUG',
        PRODUCTION: 0,
        DEV: 1,
        DEBUG: 2 },
     NodeActionType:
      { RenderElement: 'render', RunAction: 'run', RenderText: 'say' } } } 

How can we use the bp.config functions in a regular module outside a hook or action?
What do we need to import so we can use getModuleConfigForBot ?

Hey @loopmode !

Is your regular module imported by your action or hook? In that case, you could pass the sdk object from your action/hook to a function in your regular module.

Or do you invoke your custom module by another mean?

Hi.
Yeah we’re using the modules from hooks and actions to reduce code duplication, mostly utils or helpers. We’re already passing the BP object in and it works, but I’d like to avoid that if possible.