Two paths to implementing DPI Workflows: code-first for engineering teams, and no-code for practitioners. Both produce governed, auditable, interoperable services.
The DPI-AI Framework is implementation-agnostic. What matters is that workflows are governed, auditable, and use open standards. Whether you write YAML by hand or build visually in OpenFn or n8n, the governance principles remain the same.
Define workflows as YAML or JSON. Run on any workflow engine (Prefect, Airflow, custom). Full control over every step, condition, and governance parameter.
Visual workflow builder. OpenFn for DPI-native workflows, n8n for broader integrations. Drag-and-drop steps, built-in connectors to DPGs, visual governance configuration.
Define your workflow as a YAML specification. This is the source of truth β it declares the steps, the AI Blocks invoked, the governance rules, and the audit configuration. Any compliant workflow engine can run it.
Deploy to any workflow engine that can parse this spec. Recommended open-source engines:
For teams without deep engineering capacity, or for rapid pilots, visual workflow builders let you compose DPI Workflows without writing code. Both OpenFn and n8n can implement the DPI-AI Framework patterns.
OpenFn is a Digital Public Good designed specifically for social sector data integration and workflow automation. It has pre-built "adaptors" (connectors) to leading DPGs: OpenCRVS, DHIS2, Mojaloop, Kobo Toolbox, CommCare, Salesforce, and more.
Why it fits the DPI-AI Framework: OpenFn workflows can be version-controlled as code (OpenFn v2 uses a portable workflow spec), run human-in-the-loop steps, integrate with identity and payments DPGs, and log every interaction for audit. You can also call AI Blocks via HTTP adaptors.
n8n is an open-source workflow automation tool that can be self-hosted on government infrastructure. With 400+ built-in nodes and an HTTP request node for custom integrations, it can connect to any AI Block via REST API and orchestrate complex multi-step workflows visually.
Why it fits the DPI-AI Framework: n8n supports conditional branching (low-confidence β human review), webhook triggers (citizen-initiated), error handling, and logging. Workflows can be exported as JSON for version control and sharing.
Apache Airflow defines workflows as Python Directed Acyclic Graphs (DAGs). Excellent for batch processing use cases β bulk eligibility checks, crisis disbursements, registry reconciliation β where workflows run on a schedule rather than triggered by individual citizens.
A Public Agent is a constrained AI-enabled interface β not an autonomous AI system. It can only activate approved workflows, must always offer human escalation, and cannot access data without consent. Here is how to design, configure, and govern one.
Before writing any code, define in plain language what the agent CAN and CANNOT do. This becomes the governance specification.
public_agent:
name: kilimo-bot
version: "1.0.0"
owner: ministry_of_agriculture
legal_basis: "Agricultural Support Act 2025, Β§12"
channels:
primary: whatsapp_business
fallback: [ussd, sms]
languages: [sw-KE, sw-TZ, en]
scope:
can_activate:
- agri_benefit_eligibility_workflow
- farmer_registration_workflow
- support_inquiry_workflow
cannot_activate:
- payment_reversal
- registry_write_direct
- any_workflow_not_listed
constraints:
data_access: consent_required_per_session
human_escalation: always_available
escalation_channels: [human_agent_chat, phone_0800724666]
max_session_turns: 12
pii_in_logs: redacted
audit_log: required
governance:
confidence_threshold: 0.82
below_threshold: escalate_to_human
response_language: match_user_language
fallback_message: "I'm not able to help with that. Call 0800 724 666."
Design for the lowest-connectivity citizen first. Build WhatsApp β USSD β SMS as your fallback stack.
Supports voice messages (critical for low-literacy users), images, and text. Use WhatsApp Business API with a verified government number. Required: Meta verification, local telecom agreement.
Works on any phone with no internet. Session-based (β€182 chars per screen). Design menus first, not conversation flows. Works offline, real-time. Required: USSD short code from telecoms regulator.
Use for notifications only β confirmation, case ID, payment alert. Not suitable for multi-turn conversation. Keep under 160 chars. Use shortcodes for replies.
translate() AI Block to convert all inputs to your processing language and outputs back to the citizen's language.
Model selection is a governance decision, not just a technical one. Every AI Block β including those powering your Public Agent β must declare the model it uses, where it runs, and under what conditions it can be replaced.
Fastest to deploy. Most capable for complex language tasks. Data leaves your infrastructure β unsuitable for PII-heavy tasks without data processing agreements.
Data stays on your infrastructure. Full sovereignty. Requires GPU servers (A100 or equivalent) for 70B+ models. Smaller 8B models run on consumer GPUs.
Run on a single CPU server or Raspberry Pi. Ideal for single-purpose tasks: classification, entity extraction, intent detection. Cheap, fast, governable. Best choice for low-resource deployments.
Start from an open base model and fine-tune on local dialect data, government forms, and domain-specific terminology. Highest accuracy for local contexts but requires labelled data and ML expertise.
provenance:
model: "phi-3-mini-4k-instruct" # Declare the specific model
model_version: "3.8B-q4_K_M"
hosting: on_prem # sovereign_cloud | on_prem | external_api
infrastructure: "Ministry data centre, Nairobi"
replaceable: true # Can swap without rebuilding workflow
replaceability_conditions:
- "performance_below_threshold: accuracy < 0.88"
- "model_deprecated_by_vendor"
- "sovereignty_policy_change"
last_evaluated: "2026-03-01"
evaluation_dataset: "agri-sw-KE-test-v2"
Safeguards are not optional features to add later. They are structural components of the DPI Workflow, designed to prevent silent AI failures from reaching citizens. Every one of these must be in place before citizen contact.
Every AI Block must declare a minimum confidence score. Below the threshold, the system automatically escalates to a human β never delivers a low-confidence answer silently to a citizen.
confidence_threshold: 0.85
below_threshold_action: human_escalate
Escalation is not a fallback β it is a primary workflow step. Every agent interaction must have a defined escalation path with a case ID so the citizen can follow up. Never a dead end.
escalation_path: human_agent
case_id: auto_generated
timeout_before_escalate: 90s
Consent is not a checkbox in a form β it is a step in the workflow. Check it before any data access. Make it explicit, specific to purpose, and revocable.
consent.verify(citizen_id, purpose)
# blocks workflow if consent not given
Every AI inference, input hash, output, confidence score, and human decision must be logged. Logs must be immutable, time-stamped, and accessible for algorithmic audits.
audit.log(session_id, action,
confidence, outcome, actor)
Strip personally identifiable data from all logs at the point of capture β not in post-processing. ID numbers, names, and contact details must never appear in plain text in logs.
pii_handling: redact_from_logs
log_citizen_id: hashed_only
Any model in any AI Block must be replaceable without rebuilding the workflow. Declare this explicitly and test it. Digital sovereignty depends on it β vendor lock-in starts here.
replaceable: true
hosting: on_prem | sovereign_cloud
AI operates inside the DPI Workflow β not outside it. The workflow is the single source of truth. No AI output modifies a government record, triggers a payment, or affects a citizen's status without passing through the workflow's governance rules. The agent is the face. The workflow is the authority.