This repository automates the process of synchronizing data from KoboToolbox to Airtable. The script fetches survey responses from KoboToolbox, processes participant and recruiter records, checks for duplicates, and updates Airtable accordingly.
β Ensures records are not processed multiple times
- Uses
Kobo integration last processed timein Airtable to track updates. - Skips records if they have already been processed.
β Ensures participant IDs match between Kobo and Airtable
- Coerces
ID de participantfrom both sources to integers before comparing.
β Handles duplicate phone numbers correctly
- Cleans phone numbers (removes spaces, dashes, slashes, etc.).
- Checks for existing numbers in Airtable before inserting new recruits.
β Improved logging & error handling
- Stops execution if
Kobo integration last processed timefield does not exist. - Provides detailed logs for debugging.
CLIMB/
βββ kobo-airtable-sync/
β βββ src/
β β βββ kobo_to_airtable.py # π₯ Main script
β βββ config/
β β βββ config.json # Configurations (API keys, etc.)
β βββ docs/
β β βββ README.md # π This document
β βββ requirements.txt # π¦ Python dependencies
β βββ .env # π Environment variables (not in repo)
βββ .github/workflows/
β βββ kobo_to_airtable.yml # π οΈ GitHub Actions workflow
pip install -r requirements.txtDefine the following secrets in GitHub Actions or in a .env file:
KOBO_API_TOKEN=your_kobo_api_token
FORM_UID=your_kobo_form_uid
BASE_ID=your_airtable_base_id
TABLE_ID=your_airtable_table_id
AIRTABLE_API_KEY=your_airtable_api_keypython kobo-airtable-sync/src/kobo_to_airtable.py- Ensure
kobo_to_airtable.ymlis in.github/workflows/ - Trigger manually or set up a schedule
1οΈβ£ Fetch unprocessed records from KoboToolbox.
2οΈβ£ Find the corresponding participant in Airtable.
3οΈβ£ Update "RecrutΓ© par" field.
4οΈβ£ Process recruits:
- If phone number exists β Link existing record.
- If phone number does not exist β Insert new recruit.
5οΈβ£ Update "Recrues_ID" with new recruits.
6οΈβ£ Update "Statut" field.
7οΈβ£ Update "Kobo integration last processed time" in Airtable.
- "No existing participant found" error? Ensure IDs are integers in both Kobo and Airtable.
- Repeated records? Check for duplicate phone numbers in Airtable.
- GitHub Actions not triggering? Ensure
workflow_dispatchis included inkobo_to_airtable.yml.