My task is to: Create a simple program (using Google Forms > Google Sheets > Zapier > Email) that I could use to ask 10 questions to someone, and based on results, would then generate a report to give them.
I have everything figured out except the python part of Zapier, in which I am using if statements to generate the report based on their answers to specific questions. I have made a mock-up with the questions "How are you feeling?" and "What is your favourite food?" to test if it works. I cannot, for the life of me, figure out how to output the variables into the email. What am I supposed to do? I've tried using return{}
but that doesn't seem to work, giving me the wrong variables for some reason. Here's my code:
feeling=input_data
favFood=input_data
feelingReport=()
foodReport=()
if feeling == "happy":
feelingReport = ("its nice you're happy")
elif feeling == "sad":
feelingReport = ("its bad you're sad")
elif feeling == "excited":
feelingReport = ("its nice you're excited")
elif feeling == "scared":
feelingReport = ("its bad you're scared")
if favFood == "pizza":
foodReport = ("pizza is my fav too")
elif favFood == "sushi":
foodReport = ("sushi is ok i guess")
elif favFood == "burgers":
foodReport = ("i hate burgers")
output = [{'feelingReport': feelingReport, 'foodReport': foodReport}]
You can use the output statement to use the values in the next step
output = [{'feelingReport': feelingReport, 'foodReport': foodReport}]
In the image below, you can see how the values can be used in the next Zap:
Also, if the newest values aren't being pulled in, try clicking on the Refresh Fields button at the end of the Zap.
(---added the below answer after further investigation in the comments---)
Variables from the previous Zap should also be accessed through the input_data object. For example say that you used the variables data1 and data2. You should then be accessing those variables in the code like this:
feeling=input_data["data1"]
favFood=input_data["data2"]
Here's a screenshot: