I’m not very tech-savvy, and I’ve been trying to understand how to use Python within Zapier for automation.
My objective:
I need to grab information about new residents in our area from a password-protected church directory and format it into a Google Sheet. This includes details like names, addresses, and phone numbers.
The tools I’m working with:
I discovered a Python code on GitHub that claims to solve my problem. The setup process is as follows:
pip3 install lcr-api
Here’s a sample of how it’s used:
from lcr import API as ChurchAPI
api = ChurchAPI("<USER>", "<PASSWORD>", <UNITNUMBER>)
months = 5
recent_members = api.members_moved_in(months)
for member in recent_members:
print("{}: {}".format(member['spokenName'], member['textAddress']))
My current Zap setup:
I have configured it as follows: Schedule by Zapier > Get by Zapier > Code by Zapier (Python) > Google Sheets.
The issue I’m facing:
Being a novice coder, I’m unsure how to properly integrate the GitHub code within Zapier to achieve the desired data output. I’ve trialed several variations of the code in the “Get by Zapier” and “Code by Zapier” but I keep encountering errors like:
“Syntax Error in Code” and “No Data in Mapped Fields”.
For context, the data on the source site includes information such as name, age, move-in date, family role, gender, address, and phone number. I would like these to appear in distinct columns in my Google Sheet.
Can someone advise on how to set up the “Get by Zapier” and “Code by Zapier” steps to achieve the result I’m looking for?
Mike, I’ve been there with Zapier’s Python integration - it’s tricky at first. Your main issue is that Zapier’s Code step works differently than running scripts on your machine. Two things you need to fix: First, add ‘lcr-api’ to the Libraries section in your Code by Zapier settings. People miss this all the time. Second, ditch the print statements - they won’t send anything to Google Sheets. Zapier needs structured return values, so collect your member data into a proper format and return it as output_data instead. Those syntax errors? You’re probably mixing regular Python with Zapier’s weird execution environment. Start small - just connect to the API and return a test value first. Once that works, then add the member processing stuff.
hey mike, you’re overcomplicating this. skip “get by zapier” completely - don’t need it. just go schedule > code by zapier > sheets. paste that github code in the code step but change the output to return a dictionary with your column names as keys. also install the lcr-api package in code settings first
Your issue is that you’re not structuring the output correctly for Zapier. Code by Zapier needs data returned in a specific format - just printing to console won’t work for the next step. Right now you’re probably mixing GitHub example code with Zapier requirements, which causes those syntax errors. Here’s what you need to do: create a list like members_list = [], then append each member as {'name': member['spokenName'], 'address': member['textAddress'], 'phone': member.get('phone', '')}, and return {'members': members_list}. Also make sure you’ve added lcr-api under Libraries in your Code step settings.