# NhanhVN Trigger

NhanhVN Trigger on the N8N platform - a powerful workflow automation tool that allows you to create and automate complex workflows with ease. NhanhVN Trigger allows you to integrate your Nhanh.vn application with other services and applications, creating automated workflows without writing code.

{% hint style="info" %}
**Webhooks:** You can find webhooks information for this node [here](https://apidocs.nhanh.vn/webhooks/webhooks)
{% endhint %}

## Events&#x20;

* Create Order
* Create Product
* Delete Order
* Delete Product
* Inventory Change
* Update Order
* Update Product

## Example Usage

This workflow allows you to receive updates when a new product gets added in Nhanh.vn 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.

* Nhanhvn Trigger
* Set
* nhanhvn

The final workflow should look like the following image.

<figure><img src="/files/2p7TjZ82lCncilzHKYpZ" alt=""><figcaption></figcaption></figure>

### 1. Nhanhvn Trigger

The Nhanhvn Trigger node will trigger the workflow when a new product gets added in Nhanh.vn.

1. First of all, you'll have to go to [the application list](https://open.nhanh.vn/apps)&#x20;
2. Enable webhooks for your app

&#x20; 2.1 If you don't have an app yet, click "**Thêm mới**"  button to create an app

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

2.2 If you already have an app, click on the application name to go to the detail page. Click edit application, and scroll down to webhooks section:

* Check "**Bật webhooks**".
* Fill in Webhooks callback URL (must run https and response http code = 200).
* Fill in Webhooks verify token (this value is filled in by you. Nhanh API will include the webhooksVerifyToken when firing webhooks so you can verify the data is from Nhanh API firing).
* Select the events you want to register to receive webhooks and click Save.

<figure><img src="/files/4qlc6VpqieoDZ6roRrDr" alt=""><figcaption><p>Enable Webhooks</p></figcaption></figure>

3. You'll have to enter a path that you want to receive an event. Then you will copy Webhook URLs and enter this link into "Webhooks callback URL" field of your app in the step above. You can find out how to do that [here](https://apidocs.nhanh.vn/webhooks/webhooks).
4. Select 'Create Product' from the ***Events*** dropdown list.

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

5. 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 Nhanh.vn. This output gets passed on to the next node in the workflow.

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

### 2. Set node

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.data.productId}}`.
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.data.name}}`.
9. Toggle ***Keep Only Set*** to `true`. 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/KPEmjGvGk544WcHY4nyR" alt=""><figcaption></figcaption></figure>

### 3. Nhanh VN node

This node will use the data coming from the previous node to find product in nhanh.vn

1. First of all, you'll have to enter credentials for the Nhanh VN node consisting of Business ID and App ID. You can find out how to have that [here](https://apidocs.nhanh.vn/#khoi-tao-ung-dung).
2. Select 'Find Product' from the ***Operation*** dropdown list.
3. Enter the Access token in the Authentication Token field. You can find out how to get that [here](https://apidocs.nhanh.vn/#doi-access-token).
4. In n8n, paste the Access token in the **Authentication Token** field.
5. Enter the product name in the ***Product Name*** name field.
6. 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/HZwE4HSNWGZ79YEfXcNs" 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 Nhanhvn 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/nhanhvn-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.
