Example COOP integration plugin. Reference repository showing how to build a custom integration and signals for use in COOP.
- Integration config – saving and loading per-org config (e.g. “True percentage”)
- Routing rules – using the plugin signal in conditions
- Automated enforcement – the same signal in enforcement rules
- Integration:
COOP_INTEGRATION_EXAMPLE - Signal 1 – Random Signal Selection (
RANDOM_SIGNAL_SELECTION): Returnstrueorfalseat random. The probability (0–100%) comes from the org’s integration config (“True percentage”). Set e.g.70in Org settings → Integrations; the signal returnstrueabout 70% of the time. Use this to test config saving and boolean conditions. - Signal 2 – Random Score (
RANDOM_SCORE): Returns a random number between 0 and 1. No integration config needed. In the rule builder you set a threshold (e.g.0.5) and choose above or below. Use this to test numeric score conditions (e.g. “score ≥ 0.5” or “score < 0.3”).
From this repo (development):
git clone https://github.com/roostorg/coop-integration-example.git
cd coop-integration-example
npm install
npm run buildFrom npm:
npm install @roostorg/coop-integration-exampleIn your COOP integrations.config.json (or INTEGRATIONS_CONFIG_PATH), add:
Local path (development):
If you cloned this repo next to your COOP server directory, use a path relative to the server (e.g. from server/):
{
"integrations": [
{ "package": "../coop-integration-example", "enabled": true }
]
}From npm:
{
"integrations": [
{ "package": "@roostorg/coop-integration-example", "enabled": true }
]
}Restart the COOP server so it loads the plugin.
- Org settings → Integrations – you should see “COOP Integration Example”. Open it and set True percentage (0–100) (e.g.
70) for Random Signal Selection. Save. - Rules (routing or enforcement) – when adding a condition:
- Random Signal Selection: Pick that signal; the condition uses your configured percentage (true/false).
- Random Score: Pick “Random Score”, then set a threshold (e.g.
0.5) and choose above or below. The rule compares the random score to your threshold.
This package implements the COOP plugin contract from @roostorg/types:
- Default export:
CoopIntegrationPluginwithmanifestandcreateSignals(context). - Manifest:
id,name,version,requiresConfig,configurationFields,signalTypeIds,modelCard(with required sectionsmodelDetailsandtechnicalIntegration). - createSignals: Returns two descriptors:
RANDOM_SIGNAL_SELECTION:run(input)usescontext.getCredential(orgId)for true percentage; returns{ outputType: { scalarType: 'BOOLEAN' }, score: boolean }.RANDOM_SCORE:run()returns{ outputType: { scalarType: 'NUMBER' }, score: number }in [0, 1]; no config. Threshold is set in the rule (above/below).
CI runs on push/PR (build only). To publish to npm:
- Create a GitHub release (tag e.g.
v1.0.1). The Publish to npm workflow runs on release and runsnpm publish --access public. - Add NPM_TOKEN in this repo’s secrets (Settings → Secrets and variables → Actions): an npm automation token with publish permission for
@roostorg/coop-integration-example.
You can also trigger Publish to npm manually from the Actions tab (workflow_dispatch).