Skip to main content

Copy, Deploy, and Connect the Torai Google Sheet

This page explains how to copy the distributed Google Sheet, deploy its included Apps Script as a web app, and connect it to Torai. Apps Script handles automated publishing and X Marketing data collection and storage.

Process overview

  1. Copy the distributed Google Sheet from Torai
  2. Open Apps Script from the copied Sheet
  3. Confirm that the Torai code is included
  4. Deploy it as a web app
  5. Grant Google permissions
  6. Copy the web app URL
  7. Reload Google Sheets
  8. Register the GAS URL in Torai
  9. Paste the Google Sheets verification code into Torai
  10. Confirm that the Sheet is ready for publishing and X Marketing data
caution

To prevent account takeover, the connection between Apps Script and a Torai account cannot be transferred to another account. To use another Torai account, create a new Google Sheet and Apps Script project.

Before you start

  • Sign in to Torai with your Google Account
  • Sign in to the Google Account that will own the copied Sheet
  • Open Profile > API Keys in Torai

1. Copy the distributed Google Sheet

If the GAS URL and identity verification are incomplete, Torai displays Copy the Torai Google Sheet under Profile > API Keys.

Click it, then choose Make a copy on Google's copy page.

Click to get Google sheet

The Google tab for copying the sheet will open. Click the 'Make a copy' button.

Click to get Google sheet Open the distributed Google Sheet directly

caution

You cannot edit the source spreadsheet. Always make a copy in your own Google Drive.

2. Open Apps Script from the copied Sheet

Open the copied Google Sheet and click Extensions > Apps Script.

Select Apps Script from the menu

The Apps Script editor opens in another tab.

3. Confirm that the code is included

Open Code or code in the Files pane and confirm that it contains the Torai script. For a new setup, you do not need to delete the code or paste code.js from GitHub.

If the file is empty, confirm that you copied the distributed template rather than opening a blank spreadsheet.

4. Deploy as a web app

Click Deploy in the upper-right corner, then choose New deployment.

Start deployment

In the New deployment panel, click the settings icon.

Select settings

For the deployment type, select Web app.

Use these settings:

FieldSetting
DescriptionA recognizable name such as Torai publishing and analytics
Execute asMe
Who has accessAnyone

Deployment details

Click Deploy.

5. Grant Google permissions

The first time you deploy, Google asks you to grant permissions.

Click Authorize access.

Authorize access

Choose the Google Account that created the Google Sheet and Apps Script project.

If Google hasn't verified this app appears, open Advanced and continue using the project-name link.

Unverified app warning

When the page says to continue only if you understand the risks and trust the developer, click the link containing your script name.

Continue to the script

Review the permissions and click Allow.

Allow all requested access

Allow all requested access

6. Copy the web app URL

When deployment completes, the web app URL is displayed.

Click Copy.

Copy web app URL

caution

Register the web app URL ending in /exec in Torai. Do not use the Apps Script editor URL, Google Sheet URL, or a URL ending in /dev.

info

This is the URL required in Torai's settings.

7. Reload Google Sheets

Return to the Google Sheets tab after deploying Apps Script.

Click the browser's reload button.

If a Torai menu or additional sheets appear after reloading, check them.

Torai connection menu

Torai connection menu

info

Reloading applies Apps Script changes and updates the custom menu. Even if the display does not change, you can continue to the next step.

8. Register the GAS URL in Torai

Paste the web app URL you copied.

Google Sheets

9. Check Google Sheets

After the connection is complete, confirm that the required sheets and columns exist.

Check that:

  • A sheet exists for scheduled posts
  • A sheet exists for published posts
  • A sheet exists for errors
  • The verification code is no longer required or the connection is shown as complete
  • After the first X Marketing collection, XMarketingInteractions, XMarketingPosts, XMarketingPostDaily, and XMarketingRuns are created
info

Sheet and column names may change between Torai versions. After creating or automatically publishing a post, or clicking Refresh Now in X Marketing, confirm that data appears in Google Sheets.

10. Checklist before publishing or collecting data

  • All four X API credentials are registered in Torai
  • App permissions in the X Developer Console are Read and write or higher
  • X API credit and Usage have no issues
  • The GAS URL is the web app URL ending in /exec
  • Google Sheets has been reloaded
  • GAS identity verification is complete
  • If you use X Marketing, you reviewed the collection switches and monthly budget setting

Updating the Apps Script code

When Torai announces an Apps Script code update:

  1. Open the Apps Script editor
  2. Delete all old code
  3. Paste the complete new code
  4. Save
  5. Deploy a new version from Manage deployments
  6. Reload Google Sheets
  7. Test the operation in Torai

Google Sheets

caution

If you do not deploy after updating the code, the web app may continue running the old version. Do not stop after saving; redeploy when required.

Common problems

The URL produces an error in Torai

You may not have copied the Apps Script web app URL. Use the URL ending in /exec.

No verification code appears in Google Sheets

Check that:

  • Web app access is set to Anyone
  • You opened the Google Sheet used to create the Apps Script project
  • The GAS URL pasted into Torai is correct
  • You granted the required Apps Script permissions

“This GAS deployment is linked to another Torai account”

The Apps Script deployment is already linked to another Torai account and cannot be transferred.

To use another account, copy only the sheet data you need, then create a new Google Sheet and Apps Script project.

Nothing changes after replacing the code

Apps Script may need to be redeployed. In Manage deployments, create a new version and update the web app deployment.

The menu does not appear after reloading Google Sheets

Some Torai versions may not display a custom menu. Check whether GAS identity verification and post creation work in Torai.