Skip to main content

Sync Google Sheet and Hypi’s Serverless Function with Zapier

Check out this use-case of using Fenrir- Hypi's Serverless Platform

written by:
Asawari P

In this post, we will explore how to sync google sheet and Hypi’s serverless function. We will use Zapier to exchange the data between the two.

Let’s first look into Fenrir - Hypi’s Serverless platform and its functions.

Fenrir helps you deploy your own serverless function on Hypi’s low code backend. Serverless functions are helpful to manage a piece of logic at the backend. You can keep your own serverless functions ready to execute just like any other API.

Build and Deploy Serverless Function

We will use Hypi’s example nodejs serverless function already available on Hypi’s Github repository.

Download the repository and copy the source code from the nodejs folder to your preferred location on your computer. You also need to have Docker installed on your machine to deploy the function.

Detailed instructions are given on this README file on how to deploy and execute serverless functions.

Let’s build and deploy the example nodejs Serverless function. You can always write your own serverless function and deploy it on Hypi’s low code backend but we’ll start with this example.

First, authenticate Docker with Hypi Container Registry by login in.


docker login hcr.hypi.app -u hypi

Running the above command will log you into Hypi allowing you to deploy functions. It will ask for a password. Hypi accepts a token as the password, NOT your account password. You can copy the authorization token from the Hypi developer console and paste it as password.

To build the docker image, use the following command.

docker build --platform=linux/amd6 . -t hcr.hypi.app/nodejs-example:v1

nodejs-example is the name of the serverless function and v1 is version. A function may have multiple versions. The name and versions can be anything you choose but must be letters, numbers and/or hypens i.e. alphanumeric.

--platform=linux/amd6 parameter is applicable while using a platform other than linux. This means you can run this command on windows and Mac (including M1 chips).

Now let’s deploy the serverless function on Hypi’s low code backend.

docker push hcr.hypi.app/nodejs-example:v1

With this command, the serverless function is deployed and ready to execute on Hypi’s backend.

Execute Serverless Function

Now create a project on Hypi’s low code backend.

And add the below serverless function in the schema editor.

type Query {
myFnName(a: Int, b: String, c: Float, d: Boolean, e: Json): Json @fn(name:"nodejs-example", version: "v1")
}

You can have your own function in place of myFnName with your own parameters. Once you save the schema, it is time to execute this serverless function in the Playground.

{
myFnName(a:1, b:"abc", c:1.2, d:true,e:{a:"1"})
}
{
"data": {
"myFnName": {
"env": {
"hypi": {
"account_id": "01hmzhpec5g8sf661scxtfzsw9",
"instance_id": "01HNMFAASEPY9RSEYWQGRKW4GG",
"token": "eyJhb…",
"admin_token": "eyJhb…",
"domain": "minx.apps.hypi.app"
}
},
"args": {
"a": 1,
"b": "abc",
"c": 1.2,
"d": true,
"e": {
"type": "Buffer",
"data": [
123,
34,
97,
34,
58,
49,
125
]
}
}
}
}
}

The function simply returns the data you pass into it. Inside the serverless function- nodejs-example, you can have your own logic to process input parameters and create different results.

A few things to note:

env.token: is injected by the Hypi platform. It is the token used to invoke the serverless function. You can use this to make other API calls to the Hypi API as the user invoking the function.

env.admin_token is injected by the Hypi platform. Just like env.token you can use it to invoke other Hypi API calls within the function. The main difference is that the token has escalated privileges which allows the function to bypass normal permission checks and make API calls that the user invoking the function is not allowed to make. This is useful for triggering side effects, creating system data and so on but must be used with extreme care because it can allow a user to perform actions in your app that they shouldn’t be able to.

env.domain is the Hypi instance domain you can send API requests to or use as the hypi-domain header when sending requests to api.hypi.app

env.account_id is the ID of the user making the request

env.instance_id is the ID of your lowcode backend instance

Connect with Zapier

Now that our serverless function is working, we will use Zapier to connect Google Sheet with the serverless function.

We have created the below sheet with a,b,c, and d columns which are input parameters of serverless function.

sync google sheet

Whenever a row in the sheet gets updated, Zapier will recognize the trigger and convert it into an action to execute our serverless function.

So what configurations do we need in Zapier to create a Zap with above trigger and action?

To configure Trigger, use the following configurations.

sync google sheet

Select Google Sheet App and New or updated Spreadsheet Row as an event.

Enter Step details as follows.

Sync Google Sheet

Select the Spreadsheet that you want to update and also select the Worksheet from Spreadsheet to be updated. Keep the Trigger Column settings as any_column.

Now that our Trigger configurations are done. Let’s set up Action to fetch data from the Spreadsheet row and execute our serverless function with data as input parameters.

Select App as Webooks by Zapier and Event as Custom Request.

Sync Google Sheet

Select the method POST and give Hypi’s API URL - https://api.hypi.app/graphql to execute the Serverless Function. Keep Data Pass-Through setting as False.

Sync Google Sheet

Data setting is the Most Important setting where we execute the serverless function myFnName with input parameters from the Spreadsheet columns.

Enter the parameters in the Payload Data.


{"operationName":null,"variables":{},"query":"{\\n myFnName(a: 1, b: \\"abc\\", c: 1.2, d: true, e: {a: \\"1\\"})\\n}\\n"}

In place of values of a,b,c,d select the columns from the worksheet.

Keep the Data Unflattened.

Sync Google Sheet

Enter Headers as Authorization and hypi-domain. Copy the values from API settings in the Hypi Domain (https://hypi.ai/docs/lowcode/ui-gql-config) . Add another Header parameter:

Content-type as application/json.

Create the Zap and enter values in the Spreadsheet row. Make sure you are entering values as per the data type of the Columns. For Example, a is an integer.

Here is the sample Zap run result.

Sync Google Sheet

Concluding Note

This way you can use Hypi’s Fenrir serverless platform to perform operations on the data in the Google Spreadsheet.

Hope you have got the steps to sync data between Google Spreadsheet and Serverless function using Zapier. Feel free to connect with us if you have any questions.

Also try out Fenrir-Hypi’s own serverless platform!

Powered By Hypi.
Loading...
X

Still not convinced? Contact our sales team for a free demo, we’ll get you started

Make it happen! Access scalable platform for your customers needs.

Phone

By registering you agree to the Terms & Conditions