The Integrator

Connect mWater to everything
The Integrator provides two powerful ways to connect mWater with external systems:

- AI Agentic Imports: Use AI assistance to automatically import data from external APIs into mWater tables. The AI agent helps you write the code needed to fetch, transform, and map external data with no programming experience required.
- Export Integrations: Create shareable API endpoints that expose your mWater data in formats like CSV, JSON, or GeoJSON. Perfect for feeding dashboards, external tools, or other systems that need access to your mWater data.

Both features are accessible from the Integrations page in the mWater portal. This capacity aims to make connecting mWater with other systems vastly easier and in reach for the great majority of users. 
This development was funded by UNICEF MG MERL
An example AI-assisted import integration
An example AI-assisted import integration

AI Agentic Imports


What are AI Agentic Imports?
AI Agentic Imports use artificial intelligence to help you create integrations that automatically pull data from external APIs into your mWater tables. 
With the Importer you don't need to be a programmer to build integrations. You can just describe what you want to import, and the AI does the heavy lifting.

The AI agent:
- Understands your requirements through natural language
- Inspects external APIs to understand their structure
- Writes JavaScript code to fetch and transform the data
- Maps data to your mWater table schemas
- Handles authentication securely
- Supports incremental imports to only fetch new or changed data

Creating an Import Integration


1. Navigate to Import Integrations
   - Go to the Integrations page
   - Click "Manage import integrations"

2. Start a New Import
   - Click "New Import Integration"
   - Select the tableset where you want to import data
   - Choose the data source type:
     - API: Pull data from an external API on a schedule
     - Webhook: Receive data pushed to mWater by an external system

3. Describe What You Want to Import
   - In plain language, tell the AI what data you want to import
   - Examples:
     - "Import water level readings from our sensor API at https://api.example.com/sensors"
     - "Import daily rainfall data from the national weather service API"
     - "Import transaction records from our payment system at https://api.openaq.org/v3/locations?parameters_id=2&limit=1000"
   - Include details like:

4. Let the AI Agent Work
   - The AI agent will:
     1. Inspect the API to understand its structure
     2. Ask clarifying questions if needed (e.g., "Which table should this data go into?")
     3. Write the import code automatically
     4. Test the code to ensure it works
     5. Show you a preview of what will be imported

5. Review and Refine
   - Review the AI's work:
     - Check the code it generated
     - Verify the data mapping looks correct
     - Test with sample data
   - Provide feedback if needed:
     - "Change the date format"
     - "Add a filter to only import records from the last 30 days"
     - "Map this field to a different column"

6. Configure Secrets
   - If the API requires authentication, the AI will identify what credentials are needed
   - Enter API keys, tokens, or other credentials securely
   - These are encrypted and stored safely and never exposed in logs or code

7. Set Up Scheduling
   - Choose how often the import should run:
     - Manual only Run imports on-demand
     - Daily: Run at a specific time each day
     - Weekly: Run on a specific day and time
     - Monthly: Run on a specific day of the month
   - Set the time in UTC

8. Save and Activate
   - Click Save to create the integration
   - The import will run automatically according to your schedule
   - You can also trigger manual runs anytime

The Integrations Page
The Integrations Page

How the AI Agent Works


The AI agent uses a conversational approach to build your integration:

  1. Understanding Phase
    • Reads your description
    • Identifies the API endpoint and data structure
    • Determines what tables and columns are needed
  2. Exploration Phase
    • Fetches sample data from the API (if accessible)
    • Analyzes the response structure
    • Identifies data types and formats
  3. Code Generation Phase
    • Writes JavaScript code to:
      • Authenticate with the API
      • Fetch data (handling pagination if needed)
      • Transform data to match your mWater schema
      • Handle errors gracefully
  4. Mapping Phase
    • Maps external fields to mWater table columns
    • Handles data type conversions
    • Creates new tables if needed (with your approval)
  5. Testing Phase
    • Executes the code in a safe sandbox environment
    • Shows you sample results
    • Validates that data will import correctly
  6. Refinement Phase
    • Incorporates your feedback
    • Adjusts code based on your requirements
    • Re-tests until you're satisfied

You're in Control:

Scheduling and Automation

Once your import integration is set up, it runs automatically:

Schedule Options:

Incremental Imports: The AI agent can set up incremental imports that only fetch new or changed data:

Monitoring:


Import Best Practices


  1. Start Simple: Begin with a basic import, then add complexity
  2. Test First: Always test with sample data before scheduling regular imports
  3. Use Incremental Imports: When possible, configure imports to only fetch new data
  4. Secure Credentials: Never share API keys or tokens, use the secrets feature instead
  5. Monitor Regularly: Check import status periodically to catch issues early
  6. Handle Errors: Review error messages and adjust code as needed
  7. Document Your Integrations: Add clear descriptions so others understand what each integration does
  8. Respect API Limits: Be aware of rate limits on external APIs
  9. Choose Appropriate Schedules: Don't import more frequently than the source data updates
  10. Validate Data: Spot-check imported data to ensure it's correct

Export Integrations

What are Export Integrations?


Export Integrations create secure, shareable URLs that allow external systems to download your mWater data in various formats (CSV, JSON, or GeoJSON).


You control:
- Which data is exposed (by selecting tables, columns, and filters)
- How it's formatted (CSV for spreadsheets, JSON for APIs, GeoJSON for mapping tools)
- Who can access it (through role-based permissions)
- What parameters can be used to filter the data dynamically

Creating an Export Integration


1. Navigate to Integrations
2. Create a New Export
3. Select your Data Source
4. Define Columns

5. Set Up Filters (Optional)

6. Configure Variables (Optional)
Variables allow callers to filter the export via URL parameters
For example, create a region variable so users can request data for a specific region:
7. Set Ordering (Optional)

8. Configure Permissions

9. Set Limits

10. Save and Test



Using Export URLs

Once created, each export integration has a unique URL that follows this pattern:

https://api.mwater.co/integrations/export/{code}.{format}

Parameters:
- {code}: The unique code for your export integration (shown in the UI)
- {format}: One of csv, json, or geojson

Examples:

Download as CSV
https://api.mwater.co/integrations/export/abc123def456.csv

Download as JSON
https://api.mwater.co/integrations/export/abc123def456.json

Download as GeoJSON (requires geometry columns)
https://api.mwater.co/integrations/export/abc123def456.geojson

With variable parameters
https://api.mwater.co/integrations/export/abc123def456.csv?region=North&start_date=2024-01-01


Integration with External Tools:

- Google Sheets: Use IMPORTDATA() function or a script to periodically fetch the CSV URL
- Power BI / Tableau: Connect directly to the JSON or CSV endpoint
- Custom Coded Dashboards: Use JavaScript fetch() to load JSON data
- Mapping Tools: Use GeoJSON format for geographic visualizations


Export Best Practices


1. Name Clearly: Use descriptive names that indicate what data the export contains
2. Document Variables: If you use variables, document what values they accept
3. Set Reasonable Limits: Prevent accidental large exports that could impact performance
4. Test Regularly: Verify your exports still work after schema changes
5. Monitor Usage: Check download statistics to see how often your exports are used
6. Use Filters: Always filter to only export necessary data but don't export entire tables unless needed
7. Consider Permissions: Remember that anyone with the code can access the data, so protect the code accordingly. You can regenerate it if needed. 
Example Export Integration
Example Export Integration

Common Integrator Use Cases


Use Case 1: Importing Sensor Data

Scenario: You have IoT sensors that measure water levels and send data to an API. You want this data in mWater for analysis.

Solution: Use AI Agentic Import to:

Steps:

  1. Describe: "Import water level readings from https://api.sensors.com/readings"
  2. Let AI inspect API and create integration
  3. Map sensor_id to water_point_id
  4. Schedule daily imports
  5. Create visualizations in mWater using the imported data

Use Case 2: Exporting Site Data for External Dashboard

Scenario: You have a dashboard in another tool that needs to display your water point locations.

Solution: Create an Export Integration that:

Steps:

  1. Create export integration with water point table
  2. Add relevant columns
  3. Add filter: status = 'active'
  4. Share the GeoJSON URL with your dashboard tool

Use Case 3: Syncing with External Database

Scenario: Your organization uses another system for financial data, but you want to combine it with mWater survey data for reporting.

Solution: Create an import that:

Use Case 4: Webhook Integration

Scenario: An external system needs to push data to mWater in real-time (e.g., payment confirmations, form submissions).

Solution: Use Webhook Import Integration:

  1. Create a webhook endpoint in mWater
  2. Share the webhook URL with the external system
  3. Configure the AI agent to transform incoming webhook payloads
  4. Data imports automatically when the external system sends it

Getting Help

If you encounter issues:

  1. Check the error message in the import/export details
  2. Review the code (for imports) or configuration (for exports)
  3. Test with sample data to isolate the problem
  4. Contact mWater support info@mwater.co with:
    • Integration name and ID
    • Error message
    • Steps to reproduce 

Troubleshooting


Import Integration Issues

Problem: Import fails with authentication error

Problem: Import runs but no data appears

Problem: Import creates duplicate rows

Problem: AI agent doesn't understand my request

Problem: Import code has errors

Export Integration Issues

Problem: Export returns empty results

Problem: Export URL returns 404

Problem: Export is slow or times out

Problem: Variables not working in URL


info@mwater.co - Last updated 2026/2/22