I have a Python script that leverages lists in a Google Sheet and sends bulk SMS text messages using Twilio.
I'm fairly new to this and have struggled to get this far - any Python script I've created in the past, I've been able to just run off my local computer in VS Code.
I am trying to share this with a family member - I've read into tkinter and gui's a bit, but because the rest of this workflow is already in a Google Sheet, it would be perfect if any user could just run the Python script right from the spreadsheet itself.
I found this, but I don't really understand how to create a webservice in GAE. I've googled it all over but struggling to put into action -- Trigger python code from Google spreadsheets?
Is there a simple way to just tie my Python script into this spreadsheet so that anyone can run it? Or another way to go about this?
ChatGPT response says this, but I feel it is inaccurate (or I just can't get it working):
My code is here, if it helps:
from twilio.rest import Client
import gspread
# Your Account SID and Auth Token from twilio.com/console
account_sid = 'AC868ea4e1a779ff0816b466a13f201b02'
auth_token = '85469ae1eb492ffc814c095b5c6e0889'
client = Client(account_sid, auth_token)
gc = gspread.service_account(filename='creds.json')
# Open a spreadsheet by ID
sh = gc.open_by_key('1KRYITQ_O_-7exPZp8zj1VvAUPPutqtO4SrTgloCx8x4')
# Get the sheets
wk = sh.worksheet("Numbers to Send")
# E.G. the URLs are listed on Sheet 1 on Column A
numbers = wk.batch_get(('f3:f',))[0]
names = wk.batch_get(('g3:g',))[0]
# names = ['John', 'Jane', 'Jim']
# numbers = ['+16099725052', '+16099725052', '+16099725052']
# Loop through the names and numbers and send a text message to each phone number
for i in range(len(names)):
message = client.messages.create(
to=numbers[i],
from_='+18442251378',
body=f"Hello {names[i][0]}, this is a test message from Twilio.")
print(f"Message sent to {names[i]} at {numbers[i]}")

How to run a Python Script from a Google Sheet, when I saw your question, I cannot understand when you want to execute the python script from Google Spreadsheet. Can I ask you about the detailed situation for executing your python script from Google Spreadsheet? And, can I ask you about the detailed reason that you are required to use python script?I was hoping I could just share this script with someone else so they can run it via Google Sheets, if you want to run a script except for Google Apps Script by some actions in Google Spreadsheet, I thought that the HTTP request might be required to be run by Google Apps Script. If I misunderstood your expected result, I apologize.