Can we use external JS library in bot?

Hi,

I want to use external JS library for achieving Approximate match scenario.
Is it possible to load and use external JS library in Bot?

Thanks,
Neha Sheikh

Hi @nehamsheikh,

You can add external js files from Settings >> Bot functions >> upload the necessary script files.

script

Regards,
Yoga Ramya.

@nehamsheikh Please check if below steps could help in achieving the use case.

  1. Install the required npm module
  2. Reference the required library at js files of your botkit.
  3. Frame the logic at the botkit by using the functions as supported the library inside the js files of botkit.
  4. Enable botkit at the bot and subscribe to events onMessage or onHook as needed.

Consider a scenario where the developer needs to use an external library during the execution of a dialog. The dialog is designed to collect the required inputs form the user and then transition to the webhook node.

  • During runtime, when the webhook node is reached, the entire data object will be received at botkit as the bot is subscribed to onHook.
  • Inside the botkit, at the respective webhook component, the functions as supported by the library can be called by using the data present inside the context.
  • The output returned by the functions can be added to new variables of context and sent back to the platform.