Organization Power Modules
The Powers Dashboard allows for the management of organization powers and powers drafts. Organization power modules, or organization powers for short, are single file units of TypeScript code that export defined sets of functionalities. These power modules solve the problem of repeat code throughout many skills. This allows for an increase in skill behavior consistency across your organization’s custom skills while decreasing development time as new skills can leverage any number of pre-built powers to provide quicker value. This article will cover building and using organization powers.
In this Article
- How to build a Power Module
- How to use Power Modules in Skills
- Live Updates to Skills
- Power Module Risks
How to Build a Power Module
From the Powers section of the Build page, select the New Powers button at the top of the page on the Powers Dashboard. You can also clone an existing module. After creating the module, you will need to specify a Name, and then you will be redirected to the module editor. Similar to the skills builder, the Powers builder has a basic editor interface with a couple of actions, Deploy and Discard.
You are able to add any bit of code to your module, but make sure that you export what you want skills to use. Learn more here.
You will be able to leverage @andi/powers and andiskills packages to build your module. However, you currently cannot depend on other power modules.
After you finish developing your skill, you can select the Deploy button. If any skills depend on this module, you will get a warning and a list of skills just so you can confirm that these changes will not break them.
How to use Power Modules in Skills
In the Powers section of the Andi Skills Builder skill editor, you can view your power modules and do a quick import of them. A sample import might be:
import * as customMessage from "@org/custom-message";
You can leverage more granular imports by manually typing the import statement, or typing the import item and using the import action by clicking the light bulb.
JSDoc is supported for organization power modules as you can see comments are added on hover:
The currency power module looks like this:
Live Updates to Skills
If you use a power module in your skill, the skill will load the module as it starts. If you update a module that is in an enabled skill, the module’s functionality will also change in real-time. This avoids the need to update many skills if modules were versioned.
Power Module Risks
Live updates are powerful and run the risk of breaking live skills. To avoid breaking changes, clone the power module first and then test it in isolation. Once you are comfortable with your changes, update the pre-existing power module that skills use with your cloned module’s changes and discard your clone module.