# Sapo Trigger

Sapo Trigger on the N8N platform - a powerful workflow automation tool that allows you to create and automate complex workflows with ease. With Sapo Trigger, you have the ability to monitor and react to events and data from Sapo, a popular e-commerce management system. Sapo trigger allows you to create complex automated processes to interact with data from the Sapo system and make your business more efficient and save time.

{% hint style="info" %}
**Webhook:** You can find webhooks information for this node [here](https://support.sapo.vn/sapo-webhook)
{% endhint %}

## Events&#x20;

* Delete Customer&#x20;
* Delete Order&#x20;
* Delete Product&#x20;
* New Cancelled Order
* New Customer&#x20;
* New Fulfilled Order
* New Order
* New Paid Order&#x20;
* New Partially Fulfilled Order
* New Product
* Update Customer
* Update Order&#x20;
* Update Product

## Example Usage

This workflow allows you to receive updates when a new product gets added in Sapo Store and use their information to find the product. You can also find the workflow on n8n.io. This example usage workflow would use the following node.

* Sapo Authentication
* Sapo Trigger
* Edit Fields (Set)&#x20;
* Sapo

The final workflow should look like the following image.

<figure><img src="/files/AvFF4gWlLo5Fmef58h5X" alt=""><figcaption></figcaption></figure>

### 1. Sapo Authentication

This node is used to obtain access tokens for Sapo's nodes. This node is used to obtain access tokens for Sapo's nodes. How to prepare and use this node [here](https://docs.n8n.vn/sapo#2.-sapo-authentication).

### 2. Sapo Trigger

1. Select **Create new credential** at **Credential to connect with** field.

<figure><img src="/files/ok7NrvXJyyupKKGamsXy" alt=""><figcaption></figcaption></figure>

Provide your **Store Name** and **Access Token** (note: Access Token is the result of the Sapo Authentication node). After that, you can click save to finish creating credentials.

<figure><img src="/files/JFynkQbtNFOeSg0qDE6Q" alt=""><figcaption></figcaption></figure>

2. Select 'New Product' from the ***Events*** dropdown list, then you only save the workflow, it will automatically register the webhook corresponding to that event.<br>

   <figure><img src="/files/flCYlFCK2sQ3noh8ccfs" alt=""><figcaption></figcaption></figure>
3. Click on ***Execute Node*** to run the node.

In the screenshot below, you will notice that the node returns the information of the new product that was added to Sapo Store. This output gets passed on to the next node in the workflow.

<figure><img src="/files/Otpz6qNvHyCVUeRJv4c8" alt=""><figcaption></figcaption></figure>

### 3. Edit Field node (Set)

We will use the Set node to ensure that only the data that we set in this node gets passed on to the next nodes in the workflow.

1. Click on ***Add Value*** and select 'Number' from the dropdown list.
2. Enter `Product ID` in the ***Name*** field.
3. Click on the gears icon next to the ***Value*** field and click on ***Add Expression***.
4. Select the following in the ***Variable Selector*** section: Current Node > Input Data > JSON > data > productId. You can also add the following expression: `{{$json.id}}`.
5. Click on ***Add Value*** and select 'String' from the dropdown list.
6. Enter `Product Name` in the ***Name*** field.
7. Click on the gears icon next to the ***Value*** field and click on ***Add Expression***.
8. Select the following in the ***Variable Selector*** section: Current Node > Input Data > JSON > data > name. You can also add the following expression: `{{$json.name}}`.
9. Select 'Selected Input Fields' from the **Include in Output** dropdown list. We set this option to true to ensure that only the data that we have set in this node gets passed on to the next nodes in the workflow.
10. Click on ***Execute Node*** to run the node.

In the screenshot below, you will notice that the node uses the data from the previous node and returns the data that we set for the workflow.

<figure><img src="/files/EMlgu9j2OwbNLSfCxm08" alt=""><figcaption></figcaption></figure>

### 4. Sapo node

This node will use the data coming from the previous node to find product in Sapo Store

1. First of all, you'll have to enter credentials for the Sapo node consisting of Store Name and Access Token (taken from Sapo Authentication) then click **Save** button.<br>

   <figure><img src="/files/DnkwXvANo3Wel4v9rr2g" alt=""><figcaption></figcaption></figure>
2. Select 'Lấy một Product' from the ***Operation*** dropdown list.
3. Enter the Product ID in the ***Product ID*** name field.
4. Click on ***Execute Node*** to run the node.

In the screenshot below, you will notice that the node finds the information of a new product by the product name value of the previous node.

<figure><img src="/files/JkCKeIBu6Vy4KT5t0pHL" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Activate workflow for production**

You'll need to save the workflow and then click on the Activate toggle on the top right of the screen to activate the workflow. Your workflow will then be triggered as specified by the settings in the Sapo Trigger node.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-tech.n8n.vn/sapo-trigger.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
