我想构建一个问卷调查线聊天机器人并将答案传输到 Google 表格。\n这是我的代码:\n\'\'\'\nimport os
\nfrom flask import Flask, request, abort\n\nfrom linebot import (\n LineBotApi, WebhookHandler\n)\nfrom linebot.exceptions import (\n InvalidSignatureError\n)\nfrom linebot.models import (\n MessageEvent, TextMessage, TextSendMessage,\n)\nfrom oauth2client.service_account import ServiceAccountCredentials \nimport gspread\nfrom datetime import datetime, date, timedelta, time\nimport time\n\n\ngsp_scopes = [\'https://spreadsheets.google.com/feeds\']\n\nSPREAD_SHEETS_KEY = os.environ.get(\'SPREAD_SHEETS_KEY\')\ncredential_file_path = \'credentials.json\'\ndef auth_gsp_client(file_path, scopes):\n credentials = ServiceAccountCredentials.from_json_keyfile_name(file_path, scopes)\n return gspread.authorize(credentials)\n\ndef records(A, B, C, D, E):\n gsp_client = auth_gsp_client(credential_file_path, gsp_scopes)\n worksheet = gsp_client.open_by_key(SPREAD_SHEETS_KEY).sheet1\n worksheet.insert_row([A, B, C, D, E], 2)\n return True\n\napp = Flask(__name__)\n\nLINE_CHANNEL_ACCESS_TOKEN = os.environ.get(\'LINE_CHANNEL_ACCESS_TOKEN\')\nLINE_CHANNEL_SECRET = os.environ.get(\'LINE_CHANNEL_SECRET\')\nline_bot_api = LineBotApi(LINE_CHANNEL_ACCESS_TOKEN)\nhandler …Run Code Online (Sandbox Code Playgroud) python google-api google-api-python-client google-sheets-api