ILSA allows you to create and run code snippets in TypeScript to enrich vehicle data. Think of TypeScript enrichers as Webhooks hosted by us. You can write code in the Backoffice, and we’ll execute it for all your vehicles.

TIP

Start by reading about Webhooks as the TypeScript Enrichers are very similar.

You can create a new TypeScript Enricher in the Backoffice. You have to declare which fields you want to read from and which fields you want to write to. ILSA will automatically generate type definitions based on them to make your code type safe and help you prevent bugs. TypeScript will guide you to deal with any missing input values (almost all input values are optional). All output fields are optional: if you don’t return them, they’re left unchanged. You can explicitly return null for a field to unset it.

You must declare a function named handle like in the examples below. If needed, you can mark it as async and return a Promise<Output>.

You can throw an exception if your code unexpectedly fails. We’ll keep retrying until it succeeds. You can view these errors in the Backoffice.

Each time you save the code a new version will bre created. Each of your instances using this TypeScript Enricher is linked to a specific version. You can manage which version is active with the Upgrade and Downgrade buttons. This allows you to activate code changes on your dev instance before applying it to your production instance.

export function handle(input: Input): Output {
	if(input.general?.make?.normalized == 'seadoo') {
		return {
			general: {
				category: 'boat'
			}
		};
	}
	return {};
}

To communicate with external servers, you can use the Fetch API.

export async function handle(input: Input): Promise<Output> {
	const response = await fetch('https://example.com/?vin=' + encodeURIComponent(input.identification?.vin));
	if(response.status == 404) {
		// No extra information. Don't modify the vehicle.
		return {};
	}
	if(!response.ok) {
		throw new Error('No good: ' + response.status);
	}
	const data = await response.json();
	return {
		powertrain: {
			emissions: {
				class: data.emissions_class
			}
		}
	};
}