Notifications
Custom Adapters
Build your own notification adapters as plugins or npm packages.
You can extend Provenance with custom adapters for any notification target.
Option 1: Plugin files
Drop a JavaScript file in plugins/adapters/:
// plugins/adapters/slack.js
const execute = async (interaction, config, globalSettings = {}) => {
const { webhookUrl } = config;
const response = await fetch(webhookUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: `Resource ${interaction.resourceId} was updated`
})
});
return {
success: response.ok,
statusCode: response.status,
response: await response.json().catch(() => ({})),
error: response.ok ? null : response.statusText
};
};
export default { execute };Use as adapter:slack in subscription configs.
Option 2: npm packages
Publish to npm with the provenance-adapter-* naming convention:
npm install provenance-adapter-slackUse as adapter:slack — the prefix is stripped automatically.
Adapter contract
Every adapter must export an execute function:
interface AdapterResult {
success: boolean;
statusCode: number;
response: any;
error: string | null;
}
function execute(
interaction: object, // The full interaction record
config: object, // Subscription-level config
globalSettings: object // Global adapter settings
): Promise<AdapterResult>Testing adapters
Use the Provenance UI adapter browser to test your adapter with sample data before wiring it to a subscription.