This repository demonstrates how to use epilot's ERP Integration Toolkit mapping configuration (v2.0) to transform ERP system events into epilot entities.
- ERP Toolkit Mapping Documentation - Complete guide on mapping configuration
- Interactive Mapping Playground - Test and debug your mappings in the epilot portal
- epilot data model - epilot core entities documented with full json schema and examples
- JSONata Language Reference - Learn about JSONata expressions used in mappings
- epilot API Documentation - API reference
- epilot SDK - JavaScript/TypeScript SDK
This repository contains complete, working examples of:
Maps an ERP customer update to three epilot entities:
- Contact - Customer contact information
- Account - Business account details
- Billing Account - Payment and billing information
Maps an ERP order to two epilot entities:
- Contact - Customer from order
- Order - Order details with line items
.
βββ samples/
β βββ mapping.json # Mapping configuration (v2.0)
β βββ payload.customer.json # Sample CustomerChanged event
β βββ payload.order.json # Sample OrderChanged event
βββ tests/
β βββ sample-mappings.test.ts # Integration tests with expected outputs
βββ package.json
βββ README.md
- Node.js
- An epilot API token
# Clone the repository
git clone https://github.com/epilot-dev/erp-toolkit-mapping-examples.git
cd erp-toolkit-mapping-examples
# Install dependencies
npm installCreate a .env file in the project root:
# Get your API token from https://portal.epilot.cloud/app/settings/tokens
EPILOT_API_TOKEN=your_api_token_hereNote: Never commit your
.envfile to version control!
# Run all mapping tests
npm test
# Run tests in watch mode
npm run test:watchThe tests will validate that the sample events are correctly transformed into epilot entities according to the mapping configuration.
Open samples/mapping.json to see the complete mapping configuration. Key concepts demonstrated:
- Event-based mapping (v2.0 format)
- Multiple entities per event
- JSONata expressions for complex transformations
- Multi-value attributes (arrays with tags)
- Entity relations with
_setoperation - Conditional entity creation
samples/payload.customer.json- Business customer with addresses, contacts, and payment infosamples/payload.order.json- Order with line items and customer reference
The test file tests/sample-mappings.test.ts shows the exact output expected for each entity using toMatchObject assertions. This serves as living documentation of the transformation.
{
"attribute": "external_id",
"field": "customerId" // β
Direct field mapping
}{
"attribute": "full_name",
"jsonataExpression": "customerType = 'business' ? companyName : (firstName & ' ' & lastName)"
} // β
JSONata transformation{
"attribute": "email",
"jsonataExpression": "$exists(email) ? [{ \"_tags\": [\"Primary\"], \"email\": email }] : undefined"
} // β
Array with tags{
"attribute": "account",
"relations": {
"operation": "_set", // β
Relation operation
"items": [{
"entity_schema": "account",
"unique_ids": [{
"attribute": "customer_number",
"jsonataExpression": "customerId"
}]
}]
}
}{
"entity_schema": "account",
"condition": "customerType = 'business'", // β
Only create for business customers
"fields": [...]
}Each test validates the complete transformation for one entity:
it('should map to contact entity', async () => {
const response = await erpClient.simulateMapping(null, {
mapping_configuration: mappingConfig,
object_type: 'CustomerChanged',
format: 'json',
payload: JSON.stringify(event),
});
const contactUpdate = response.data.entity_updates.find(
(update) => update.entity_slug === 'contact'
);
// Expected output documented here
expect(contactUpdate).toMatchObject({
entity_slug: 'contact',
attributes: {
external_id: 'CUST-9876',
full_name: 'Acme Corporation',
email: [{ _tags: ['Primary'], email: 'max.mustermann@acme.com' }],
// ... complete expected structure
}
});
});- Modify the mapping in
samples/mapping.jsonto match your ERP data structure - Update sample payloads in
samples/*.jsonwith your actual event format - Run tests to validate your mappings work correctly
- Deploy the mapping configuration to your epilot organization
{
"attribute": "my_custom_field",
"field": "sourceField"
}{
"attribute": "company_name",
"jsonataExpression": "$exists(companyName) ? companyName : undefined"
}{
"attribute": "order_items",
"jsonataExpression": "items.{ \"product_id\": productId, \"quantity\": $string(quantity) }"
}{
"attribute": "related_entity",
"relations": {
"operation": "_set",
"items": [{
"entity_schema": "target_schema",
"unique_ids": [{ "attribute": "unique_field", "field": "sourceField" }]
}]
}
}