r/GoogleAppsScript • • Feb 27 '21

Question Connecting a google form to a Python code

So, I’m working on this project, that consist on a culinary recipes recommender system. Basically, I would like to send the recommended recipe link on a google form, so I can get the feedback. The problem is that the link to be sent -and some other stuff - are generated on a python code. Does anybody knows how to connect this two-the link generated from the python code to the app script that creates the form?

6 Upvotes

9 comments sorted by

3

u/TobofCob Feb 28 '21

You can call the apps script API from Python as long as you aren’t using a service account to run the Python code. Sounds like that would be a good option, have you tried looking at the documentation for calling an Apps Script function from Python?

1

u/marcelowiski Feb 28 '21

Oh I didn’t know that. Thanks for the tip

1

u/pilly-bilgrim Feb 28 '21

This! It works great

2

u/7FOOT7 Feb 27 '21

So the python runs locally?

I've tried to do this, but I fell down badly at the part that sends local content "online" for sheets to access

Will watch for solutions

2

u/marcelowiski Feb 27 '21

For now, It runs locally, but it is not a problem to change that.

2

u/fergal-dude Feb 28 '21

Ok, so here it goes, it’s totally possible but you are going to have to be handy.

This course will show you how to dynamically change Google Forms with apps script. https://courses.benlcollins.com/p/apps-script-blastoff

By checking the apps script docs you should be able to figure out how to create new forms, or a copy of a standard form and change the text/questions.

I use pygsheets https://github.com/nithinmurali/pygsheets all the time to interect with google sheets from python.

If you know your way around Python, you should be able to pull this off between the two. You should be able to put your data from python into a list or dict and write that to a new line in a google sheet and then work a trigger in apps script to generate and send a from link through gmail.

Good luck.

1

u/marcelowiski Feb 28 '21

Thanks man. Helped a lot

1

u/macorreag Feb 28 '21

You can make a data connection by creating a Python Notebook in Google Colab. In this video they explain it clearly.

1

u/marcelowiski Feb 28 '21

Thanks! I will watch that