This article will provide the Google Apps Script code necessary to have your Google Sheets (and Google Forms) push content directly into Ryver.
Our example involves creating a Google Sheet, and then a corresponding Google Form that can be used to ask people what integrations they would like to see with our product. When somebody submits a form, it populates the spreadsheet and triggers a Google Apps Script that will call a Ryver webhook to create a new task in a private team. Creating a team task requires a free trial or paid subscription to Ryver Task Manager.
Note: If you don’t have the Ryver Task Manager enabled for teams, you can follow all of the same steps, just select “Post” for your webhook type in step one instead of “Task”.
- Create a Ryver incoming webhook
First, you’ll need somebody with Admin privileges in Ryver to set up a webhook for the type of content you want to create. Just create a “Plain text/Ryver” webhook that will create a new task (or post) in a private team. See the Incoming Webooks article for more on how they work. - Create Google Sheet and Google Form
For this example, we’re going to use a Google Form to populate our spreadsheet, and then trigger off of the form submission to call the Ryver webhook. After creating your new Google Sheet, select Tools > Create a form. Our form has three fields: A short text integration name (the product you want to integrate), a radio button to indicate if the product supports outbound webhooks, and then the type of Ryver content you want to create. - Add script to the spreadsheet
Back in the Google Sheet, select Tools > Script Editor. Paste the code from this Google Gist into the script editor, replacing the placeholder code and replace the url with your webhook URL from step 1. Save the script. When a form is submitted, the event (e), passed to the script, will contain the values from the submitted form that are inserted into the spreadsheet. - Set the trigger for executing the callWebhook(e) function.
In order for the script to be called, we need to set a “trigger”. In this case, we’re going to trigger off of the submission of the form. With the Script Editor still open, select Edit > Current project’s triggers. Add a new trigger to run callWebhook() from spreadsheet on form submit. Save.
- Submit a form and look in your Ryver team.
You should see a new task (or post if you created a post webhook) with the details from the integration request.
Integrating with Google Sheets, but no Google Form
If you would prefer to trigger the webhook call off of a direct edit in the spreadsheet, rather than a form post, you can do that as well. When creating your trigger, one of the options after you choose From spreadsheet is On Edit. If you use this trigger, then the event (e) value is going to be different from the example above.
When triggered on edit, the e parameter will be a range object. Let’s say you want to call a Ryver webhook when a new value is added to the second column in your spreadsheet. You could do something like:
if (e.range.getColumn() == 2) { var payload = { "subject" : "Integration Request: " + e.range.getValue(), }; sendToRyver_(url, payload); }