Editor Mode Test Parses data, but when I use a live zap, it returns null for every value

The Python script below is designed to parse text from a Slack notification and convert it into structured data. This structured data is then mapped to the Zapier inputs for further processing. The Slack messages are inputted into the keyName and subsequently mapped to the respective Zapier inputs.

The issue arises when attempting to run the live Zap: the parsed data fields are all blank. However, during the Zapier Edit Mode, the parsing works correctly when tested manually. Despite reaching out to Zapier Support for assistance, they were unable to resolve the issue since it involves custom code, and they suggested seeking help from external sources.

In this context, the goal is to ensure that the Python script reliably parses the Slack notification text in both the Edit Mode and live execution of the Zap. Any help in diagnosing and resolving this issue would be greatly appreciated, as it is critical for the workflow’s automation

import re

#Input text from Zapier

text = input_data.get('keyName', '')

#Function to parse the text and extract specified sections

def extract_sections(text): sections = {}
# Extract Business Objectives
business_objectives_match = re.search(r'Business Objectives:n(.*?)(?:nn|Z)', text, re.DOTALL)
if business_objectives_match:
    business_objectives = business_objectives_match.group(1).strip().split('n')
    sections['Business Objectives'] = [re.sub(r'^d+.s*', '', obj.strip()) for obj in business_objectives]

# Extract Pain Quotes
pain_quotes_match = re.search(r'Pain Quotes:n(.*?)(?:nn|Z)', text, re.DOTALL)
if pain_quotes_match:
    pain_quotes = pain_quotes_match.group(1).strip().split('n')
    sections['Pain Quotes'] = [re.sub(r'^d+.s*', '', quote.strip('"')) for quote in pain_quotes]

# Extract Desired Outcomes
desired_outcomes_match = re.search(r'Desired Outcomes:n(.*?)(?:nn|Z)', text, re.DOTALL)
if desired_outcomes_match:
    desired_outcomes = desired_outcomes_match.group(1).strip().split('n')
    sections['Desired Outcomes'] = [re.sub(r'^d+.s*', '', outcome.strip()) for outcome in desired_outcomes]

# Extract Primary Buying Motive
primary_buying_motive_match = re.search(r'Primary Buying Motive:n(.*?)(?:nn|Z)', text, re.DOTALL)
if primary_buying_motive_match:
    sections['Primary Buying Motive'] = primary_buying_motive_match.group(1).strip()

# Extract From, To Statements
from_to_match = re.search(r'From, To Statements:n(.*?)(?:nn|Z)', text, re.DOTALL)
if from_to_match:
    from_to_statements = from_to_match.group(1).strip().split('n')
    sections['From, To Statements'] = [statement.strip() for statement in from_to_statements]

# Extract Primary Contact
primary_contact_match = re.search(r',*Primary Contact* n,(.*?), Email: <mailto:(.*?)|.*?>', text)
if primary_contact_match:
    sections['Full Name'] = primary_contact_match.group(1).strip()
    sections['Email'] = primary_contact_match.group(2).strip()

# Extract Summary Titles
summary_titles_match = re.search(r',*Summary Titles* n(.*?)(?:Z)', text, re.DOTALL)
if summary_titles_match:
    sections['Summary Titles'] = summary_titles_match.group(1).strip()

return sections

# Function to parse "From, To Statements"

def parse_from_to_statements(statements): from_to_pairs = [] for statement in statements: from_part, _, to_part = statement.partition(' to ') from_part = from_part.replace('From ', '').strip() from_to_pairs.append((re.sub(r'^d+.s*', '', from_part), to_part.strip())) return from_to_pairs

# Extract the sections from the text

sections = extract_sections(text)

#Parse the "From, To Statements"

parsed_from_to = parse_from_to_statements(sections.get('From, To Statements', []))

#Preparing the output dictionary with specific fields

output = { "business_objectives_1": sections.get('Business Objectives', ["", "", ""])[0], "business_objectives_2": sections.get('Business Objectives', ["", "", ""])[1], "business_objectives_3": sections.get('Business Objectives', ["", "", ""])[2], "pain_quotes_1": sections.get('Pain Quotes', ["", "", ""])[0], "pain_quotes_2": sections.get('Pain Quotes', ["", "", ""])[1], "pain_quotes_3": sections.get('Pain Quotes', ["", "", ""])[2], "desired_outcomes_1": sections.get('Desired Outcomes', ["", "", ""])[0], "desired_outcomes_2": sections.get('Desired Outcomes', ["", "", ""])[1], "desired_outcomes_3": sections.get('Desired Outcomes', ["", "", ""])[2], "primary_buying_motive": sections.get('Primary Buying Motive', ""), "from_1": parsed_from_to[0][0] if len(parsed_from_to) > 0 else "", "to_1": parsed_from_to[0][1] if len(parsed_from_to) > 0 else "", "from_2": parsed_from_to[1][0] if len(parsed_from_to) > 1 else "", "to_2": parsed_from_to[1][1] if len(parsed_from_to) > 1 else "", "from_3": parsed_from_to[2][0] if len(parsed_from_to) > 2 else "", "to_3": parsed_from_to[2][1] if len(parsed_from_to) > 2 else "", "full_name": sections.get('Full Name', ""), "email": sections.get('Email', ""), "summary_titles": sections.get('Summary Titles', "") }

#Output the result (in a real scenario, you might want to return this or process further)

print(output)

New contributor

Cjb936 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật