Skip to content

datapopalliance/CLIMB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

67 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ KoboToolbox to Airtable Sync

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.

πŸš€ Features & Updates

βœ… Ensures records are not processed multiple times

  • Uses Kobo integration last processed time in Airtable to track updates.
  • Skips records if they have already been processed.

βœ… Ensures participant IDs match between Kobo and Airtable

  • Coerces ID de participant from 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 time field does not exist.
  • Provides detailed logs for debugging.

πŸ“‚ Repository Structure

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

βš™οΈ Setup & Configuration

1️⃣ Install dependencies

pip install -r requirements.txt

2️⃣ Set up environment variables

Define 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_key

3️⃣ Run the script locally

python kobo-airtable-sync/src/kobo_to_airtable.py

4️⃣ Automate with GitHub Actions

  • Ensure kobo_to_airtable.yml is in .github/workflows/
  • Trigger manually or set up a schedule

πŸ” Workflow Overview

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.

πŸš‘ Troubleshooting

  • "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_dispatch is included in kobo_to_airtable.yml.

About

CLIMB

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages