---
updatedAt: 2026-06-25T20:26:55.000Z
agentTools:
  projectIndex: https://developer.trulioo.com/llms.txt
---

# Event Dispatcher

```shell Shell
import json

# Sample anonymized payload
payload = '''{
    "id": "sample-id",
    "token": "sample-token",
    "type": "EVENT_CALLBACK",
    "event": {
        "type": "SERVICE_SUBMIT",
        "ts": 1718011363,
        "user": "sample-user-id"
    },
    "flowId": "sample-flow-id",
    "userId": "sample-user-id",
    "serviceType": "TRULIOO_EIDV",
    "test": true,
    "retry": 0,
    "serviceData": {
        "timestamp": 1718011363,
        "serviceStatus": "COMPLETED",
        "match": true,
        "transactionInfo": {
            "accountName": "sample-account-name",
            "accountIdentifier": "sample-account-identifier",
            "countryCode": "US",
            "date": "2022-11-22T12:00:00Z",
            "transactionId": "sample-transaction-id",
            "transactionRecordId": "sample-transaction-record-id",
            "userName": "sample-username"
        },
        "secondaryMatch": null
    }
}'''

# List of service types to be processed
valid_service_types = [
    "TRULIOO_EIDV", "TRULIOO_KYB_SEARCH", "TRULIOO_KYB_VERIFY",
    "TRULIOO_KYB_INSIGHTS", "TRULIOO_KYB_COMPLETE", "TRULIOO_DOCV",
    "TRULIOO_UTILITY_ID", "TRULIOO_PERSON_WL", "TRULIOO_BUSINESS_WL",
    "TRULIOO_ELECTRONIC_ID"
]

# Function to evaluate the match status from the service data
def evaluate_service_data(service_data, service_type):
    match_status = service_data.get('serviceStatus') == "COMPLETED" and service_data.get('match') == True
    return f"{service_type} - match({match_status})"

# Function to process the event
def process_event(event_payload):
    try:
        data = json.loads(event_payload)
        service_data = data.get('serviceData')
        service_type = data.get('serviceType')
        
        if service_data and service_type in valid_service_types:
            evaluation_result = evaluate_service_data(service_data, service_type)
            print(evaluation_result)
        else:
            print("No valid service data found or service type not supported")
    except Exception as e:
        print(f"Error processing event: {str(e)}")

# Process the sample payload
process_event(payload)

```

```json Response Example
{"success":true}
```

# 1. Sample event

<!-- shell@3-33 -->

The code includes a sample anonymized payload representing an event. A list of valid service types specifies which service types should be processed.

# 2. Evaluate service data

<!-- shell@35-46 -->

The evaluate_service_data function checks if serviceStatus is "COMPLETED" and returns the result in the format "{service_type} - match(true/false)".

# 3. Process the event

<!-- shell@49-62 -->

The process_event function parses the JSON payload, extracts serviceData and serviceType, and checks if serviceType is in valid_service_types.