How To
Trigger an automation from Google Sheet
Trigger an automation from an event in a Google Sheet
Setting Up a Google Sheets Trigger for Pinkfish
This guide will walk you through the process of setting up an Apps Script in a Google Sheet that fires on form submission and triggers a Pinkfish automation.
Step 1: Open Script Editor
- Open your Google Sheet.
- Click “Extensions” in the menu bar.
- Select “Apps Script” from the dropdown menu.
Step 2: Write the Script
In the script editor, paste the following code:
Step 3: Configure the Script
- Replace
YOUR_API_KEY_HERE
with your actual Pinkfish API key. - Replace
YOUR_TRIGGER_ID
in the URL with your actual Pinkfish trigger ID.
Step 4: Set Up the Trigger
- In the script editor, click on the clock icon on the left sidebar to open the project triggers.
- Click the ”+ Add Trigger” button in the bottom right corner.
- In the “Choose which function to run” dropdown, select
onFormSubmit
. - Under “Select event source”, choose “From spreadsheet”.
- For “Select event type”, choose “On form submit”.
- Click “Save”.
Step 5: Authorize the Script
- You may be prompted to authorize the script to access your Google Sheet and make external requests.
- Follow the prompts to grant the necessary permissions.
Step 6: Test Your Automation
- Submit a form linked to your Google Sheet.
- Check the script logs (in the script editor, click “Execution Log”) to see if the form submission was detected and the Pinkfish trigger was called successfully. You can also see the list of executions by clicking the “Executions” button in the left-side navigation.
How It Works
- When a form is submitted, the
onFormSubmit
function is triggered. - The script extracts the form data, including headers and values.
- It formats the data and adds the row number of the new entry.
- The script then makes a POST request to the specified Pinkfish trigger URL, including the form data and your API key.
- The response from the Pinkfish API is logged for debugging purposes. Note that the response will be blank, but there should be a runId in the headers.
Troubleshooting
If you encounter any issues:
- Check the script logs for error messages.
- Verify that your API key and trigger URL are correct.
- Ensure that your Google Sheet is properly linked to a form.
- Check the Pinkfish Runs Monitor to see the form data come into your automation.
Congratulations! You’ve now set up a Google Sheets trigger that automatically sends form submission data to your Pinkfish automation. Happy automating!