Function Library: Create and share global functions in your bots January 16, 2025 13:50 Updated Index: What is the Function Library? Advantages of the Function Library How to create a function? Configurable parameters of a function Editing a function Deleting a function Impact warnings How to use a created function? What is the Function Library? The Function Library is located in the Actions section of the Builder blocks. It allows botmakers to create global JavaScript functions that can be accessed by all bots in a connected contract. With the Function Library, you centralize and reuse common logic across bots, reducing redundancy and increasing consistency. Image 01: Location of the Function Library in the Builder Advantages of the Function Library Centralization and Reusability: Create functions in one place and use them across multiple bots.Simplified Maintenance: Update a centralized function and propagate the changes to all bots that use it.Error Reduction: Decrease code duplication and the risks of inconsistencies.Ease of Management: Simple and intuitive interface to create, edit, and delete functions. How to create a function? There are three ways to create a new function in the Function Library: Within a block in the Builder: Go to the Actions tab. Click the Create Function button. Through the Function Library Management: Access the Function Library directly. Click the Create Function button. In a "Function from the Library" action: When configuring a "Function from the Library" action, click the Create Function button. Configurable parameters of a function Key: The function name. It can contain uppercase or lowercase characters but should not include spaces or special characters. Description (Optional): A brief explanation to help understand the function. Input Variables: Parameters that the JavaScript function will receive. Function Content: The JavaScript code that will be associated with the function. Tip: Use the Expand Content button to open a larger and more convenient code editor. Image 02: Configurable parameters of a function Editing a function Go to the list of functions. Click on the three-dot icon next to the desired function. Select the Edit option. Make the necessary adjustments to the function's parameters. Click the Save Changes button to apply the updates. Deleting a function Go to the list of functions. Click on the three-dot icon next to the desired function. Select the Delete option. Impact Warnings When editing or deleting a function, the system will display a warning to avoid unintended impacts: Deletion: If the function is used by other bots: The system will list the affected bots. It will provide links to access those bots. Deletion will be blocked until the function is manually removed from those bots. If the function is not in use: The system will allow deletion without restrictions. Editing: If the function is used by other bots: The system will list the affected bots and allow editing. If the function is not in use: Editing will be allowed without restrictions. Image 03: Impact warning when editing a function How to use a created function? There are two main ways to use a function created in the Function Library: Using in an "Execute Script 2.0" action: Create an input/output action of type Execute Script 2.0. To invoke the function, use the following format:{{blipfunction.key}} blipfunction: The default prefix for the Function Library (cannot be changed). key: The name of the created function. Complete the action configuration as needed. Image 04: Calling a function from the Library in the 'Execute Script 2' action Using in a "Library Function" action: Create an input/output action of type Library Function. From the list of available functions, select the desired function. Configure the remaining parameters as needed. Image 05: Selecting a function in the 'Library Function' action For more information, visit the discussion on this topic in our community or the videos on our channel. 😃 Related articles TabMonitor Extension Builder variables How to send WhatsApp notifications through Blip API Sending WhatsApp Active Messages on Blip Desk Action: Run script