Zapier

Integrating Zapier as a Source with GlassFlow Using Webhook Connector

Zapier is a popular automation platform that connects to your favorite apps and services to automate repetitive tasks and streamline your workflows. With the Zapier and GlassFlow integration, you can automatically send updates from any of the thousands of apps and services supported by Zapier to a GlassFlow pipeline via Webhook Connector.

This tutorial will guide you through setting up an integration between Zapier and GlassFlow. One of the good examples to demonstrate this is how you keep your data in sync and enrich. Think about every time a row in your Google Sheets spreadsheet is updated, Zapier will send a POST request to the GlassFlow webhook. The GlassFlow pipeline processes, transforms and sends the output data to other related systems (e.g., CRM, marketing tools, analytics platforms) in real-time.

Pipeline components

  • Data Source: The data source for this pipeline is Zapier. GlassFlow pipeline is triggered by receiving POST requests from Zapier using the GlassFlow Webhook connector whenever a row in your Google Sheets is updated.

  • Transformation: You define a transformation function to process the incoming data. This could include tasks like data cleaning, enrichment, or applying business logic.

  • Data Sink: After processing, the data can be sent to any configured data sink, such as a database, analytics platform, or another API.

Example Use Case Data

Let's assume your Google Sheets tracks customer orders:

Order IDCustomer NameProductQuantityStatus

1001

Jane Doe

Widget

2

Completed

1002

John Smith

Gizmo

1

Pending

Every time an order is updated (e.g., status changes from "Pending" to "Completed"), Zapier sends the update to GlassFlow via the webhook URL. GlassFlow processes this update, enriching it with additional information (like the customer's previous order history or shipping details), and sends it to your CRM or analytics dashboard.

Setting Up the Pipeline with GlassFlow

You will use the GlassFlow WebApp to create a data processing pipeline.

Prerequisites

To start with this setup, you need a free GlassFlow account.

Sign up for a free account

Step 1. Log in to GlassFlow WebApp

Navigate to the GlassFlow WebApp and log in with your credentials.

Step 2. Create a New Pipeline

Click on "Create New Pipeline" and give it a name like "Google Sheets Updates."

Step 3. Configure the Webhook Data Source

Choose "Webhook" as the Data Source type. GlassFlow will provide you with a unique webhook URL for your pipeline after the pipeline is created.

Step 4. Define the Transformer

Define the transformation function in the pipeline. This function cleans the incoming data and adds some metadata before sending it to the next stage in the pipeline.

Copy and paste the following transformation function code into the transformer's built-in editor.

import json

def handler(data, log):
    log.info("Event received: " + json.dumps(data))

    # Example transformation: Clean and enrich data
    transformed_data = {
        "order_id": data.get("Order ID"),
        "customer_name": data.get("Customer Name").title(),
        "product": data.get("Product").capitalize(),
        "quantity": int(data.get("Quantity", 0)),
        "status": data.get("Status").lower(),
        "processed_at": data.get("timestamp", "N/A"),  # Add processing timestamp
        "source": "Google Sheets via Zapier"
    }

    log.info("Transformed Data: " + json.dumps(transformed_data))
    return transformed_data

Note that the handler function is mandatory to implement in your code. Without it, the transformation function will not be successful.

Step 5. Configure a Data Sink

Select "SDK" to configure the pipeline to use Python SDK to send output data to the desired destination. For simplicity, you can consume the transformed data from the GlassFlow pipeline and print it to the console. See consume data from the pipeline section below.

Step 6. Confirm the Pipeline

Confirm the pipeline settings in the final step and click "Create Pipeline".

Step 7. Copy the Webhook URL and Pipeline Credentials

Once the pipeline is created, copy its Access Token and Webhook URL specific to this pipeline on the "Details" page.

Set Up Zapier to Send Data to GlassFlow

Step 1. Create a New Zap:

  • Log in to your Zapier account.

  • Click on "Make a Zap" to create a new automation.

Step 2. Choose Google Sheets as the Trigger App:

  • Set Google Sheets as the trigger app.

  • Select the trigger event "New or Updated Spreadsheet Row." This ensures that Zapier triggers whenever a row is added or updated in your Google Sheets. Or you can also use a ready template called: Send webhook POSTs with new updates to Google Sheets rows

Step 3. Connect Your Google Account:

  • Connect your Google account and select the specific spreadsheet and worksheet you'd like to monitor.

Step 4. Set Up the Action to Send Data to GlassFlow:

  • Choose "Webhook" as the action app.

  • Select the action event "POST."

  • In the "URL" field, paste the GlassFlow webhook URL you copied earlier.

  • In the "Payload Type" field, choose "JSON."

  • Map the fields from your Google Sheets row to the corresponding JSON keys. For example, if your spreadsheet has columns for "Order ID," "Customer Name," and "Status," map these to JSON keys like "Order ID": "1001", "Customer Name": "Jane Doe", etc.

  • For the Headers, add one header with the following key and value pair: X-Pipeline-Access-Token and your pipeline Access Token

Step 5.Test and Activate Your Zap:

  • Test the Zap to ensure it's working correctly. Zapier will send a sample POST request to your GlassFlow pipeline.

  • Once the test is successful, activate the Zap.

Consume data from the pipeline

Prerequisites

To complete this part you'll need the following:

Create an example consumer with Python SDK

You can consume the transformed data from the GlassFlow pipeline using managed connectors or implement a custom sink integration using Python SDK. For the sake of the demo, we can print it to the console using the below consumer.py Python script. Here's an example of how to implement this:

import glassflow

pipeline_client = glassflow.GlassFlowClient().pipeline_client(
	pipeline_id="your_pipeline_id",
	pipeline_access_token="your_pipeline_access_token"
)
response = pipeline_client.consume()

if response.status_code == 200:
	data = response.json()
	print("Consumed Data: ", data)

Replace your_pipeline_id and your_pipeline_access_token with appropriate values obtained from your GlassFlow account.

Run the pipeline

Run consumer.py Python script in a terminal to consume data from the GlassFlow pipeline:

python consumer.py

This script will continuously consume new events from the GlassFlow pipeline. Upon receiving transformed events, it will print data in the console.

Consumed Data:  {'order_id': '1001', 'customer_name': 'Jane Doe', 'product': 'Widget', 'quantity': 2, 'status': 'completed', 'processed_at': 'N/A', 'source': 'Google Sheets via Zapier'}

Also, you can see processed event logs in the GlassFlow Pipeline Logs section.

This integration can be replaced with any other integrations that Zapier connects to.

If you're ready to use this foundational setup, start by creating your GlassFlow pipeline and connecting it to Zapier today!

Last updated

Logo

© 2023 GlassFlow