Merge branch 'docs/rabbitmq'

This commit is contained in:
Tanay Pant 2020-12-24 18:54:56 +01:00
commit 14669120dd
13 changed files with 198 additions and 0 deletions

View File

@ -0,0 +1,18 @@
---
permalink: /credentials/rabbitmq
description: Learn to configure credentials for the RabbitMQ node in n8n
---
# RabbitMQ
You can use these credentials to authenticate the following nodes with RabbitMQ.
- [RabbitMQ](../../nodes-library/nodes/RabbitMQ/README.md)
- [RabbitMQ Trigger](../../nodes-library/trigger-nodes/RabbitMQTrigger/README.md)
## Prerequisites
You need to have a RabbitMQ broker installed.
## Using RabbitMQ
Use your Hostname, Port, Username, Password, and Vhost as the RabbitMQ credential data in n8n.

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

View File

@ -0,0 +1,94 @@
---
permalink: /nodes/n8n-nodes-base.rabbitmq
description: Learn how to use the RabbitMQ node in n8n
---
# RabbitMQ
[RabbitMQ](https://www.rabbitmq.com) is an open-source message broker that accepts and forwards messages.
::: tip 🔑 Credentials
You can find authentication information for this node [here](../../../credentials/RabbitMQ/README.md).
:::
## Example Usage
This workflow allows you to send updates about the position of the ISS every minute to a queue using the RabbitMQ node. You can also find the [workflow](https://n8n.io/workflows/844) on n8n.io. This example usage workflow uses the following nodes.
- [Cron](../../core-nodes/Cron/README.md)
- [HTTP Request](../../core-nodes/HTTPRequest/README.md)
- [Set](../../core-nodes/Set/README.md)
- [RabbitMQ]()
The final workflow should look like the following image.
![A workflow with the RabbitMQ node](./workflow.png)
### 1. Cron node
The Cron node will trigger the workflow every minute.
1. Click on ***Add Cron Time***.
2. Select 'Every Minute' from the ***Mode*** dropdown list.
3. Click on ***Execute Node*** to run the node.
In the screenshot below, you will notice that the Cron node is configured to trigger the workflow every minute.
![Using the Cron node to trigger the workflow every minute](./Cron_node.png)
### 2. HTTP Request node (GET)
This node will make a GET request to the API `https://api.wheretheiss.at/v1/satellites/25544/positions` to fetch the position of the ISS. This information gets passed on to the next node in the workflow.
::: v-pre
1. Enter `https://api.wheretheiss.at/v1/satellites/25544/positions` in the ***URL*** field.
2. Click on the ***Add Parameter*** button in the ***Query Parameters*** section.
3. Enter `timestamps` in the ***Name*** field.
4. Click on the gears icon next to the ***Value*** field and click on ***Add Expression***.
5. Enter the following expression: `{{Date.now()}}`. This expression will return the current timestamp.
6. Click on ***Execute Node*** to run the node.
:::
In the screenshot below, you will notice that the node makes a GET request to the API and returns the information about the location of the ISS.
![Using the HTTP Request node to get the information about the location of the ISS](./HTTPRequest_node.png)
### 3. 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.
::: v-pre
1. Click on ***Add Value*** and select 'String' from the dropdown list.
2. Enter `Name` 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: Nodes > HTTP Request > Output Data > JSON > 0 > name. You can also add the following expression: `{{$node["HTTP Request"].json["0"]["name"]}}`.
5. Click on ***Add Value*** and select 'String' from the dropdown list.
6. Enter `Latitude` 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: Nodes > HTTP Request > Output Data > JSON > 0 > latitude. You can also add the following expression: `{{$node["HTTP Request"].json["0"]["latitude"]}}`.
9. Click on ***Add Value*** and select 'String' from the dropdown list.
10. Enter `Longitude` in the ***Name*** field.
11. Click on the gears icon next to the ***Value*** field and click on ***Add Expression***.
12. Select the following in the ***Variable Selector*** section: Nodes > HTTP Request > Output Data > JSON > 0 > longitude. You can also add the following expression: `{{$node["HTTP Request"].json["0"]["longitude"]}}`.
13. Click on ***Add Value*** and select 'String' from the dropdown list.
14. Enter `Timestamp` in the ***Name*** field.
15. Click on the gears icon next to the ***Value*** field and click on ***Add Expression***.
16. Select the following in the ***Variable Selector*** section: Nodes > HTTP Request > Output Data > JSON > 0 > timpestamp. You can also add the following expression: `{{$node["HTTP Request"].json["0"]["timestamp"]}}`.
17. 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 get passed on to the next nodes in the workflow.
18. 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.
![Using the Set node to set the data](./Set_node.png)
### 4. RabbitMQ node
This node will send the data from the previous node to the `iss-position` queue in RabbitMQ. If you have created a queue with a different name in RabbitMQ, you can use that queue instead.
1. First of all, you'll have to enter credentials for the RabbitMQ node. You can find out how to do that [here](../../../credentials/RabbitMQ/README.md).
2. Enter the name of the queue or topic in the ***Queue / Topic*** field.
3. Click on ***Execute Node*** to run the node.
In the screenshot below, you will notice that the node sends the data from the previous node to the `iss-position` queue in RabbitMQ.
![Using the RabbitMQ node to send the data to a queue](./RabbitMQ_node.png)
::: tip 💡 Activate workflow for production
This example workflow uses the Cron node, which is a Trigger node. 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 Cron node.
:::

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

View File

@ -0,0 +1,86 @@
---
permalink: /nodes/n8n-nodes-base.rabbitmqTrigger
description: Learn how to use the RabbitMQ Trigger node in n8n
---
# RabbitMQ Trigger
[RabbitMQ](https://www.rabbitmq.com) is an open-source message broker that accepts and forwards messages.
::: tip 🔑 Credentials
You can find authentication information for this node [here](../../../credentials/RabbitMQ/README.md).
:::
## Example Usage
This workflow allows you to receive messages from a queue and send an SMS if the value of the temperature is greater than 50. You can also find the [workflow](https://n8n.io/workflows/845) on n8n.io. This example usage workflow would use the following nodes.
- [RabbitMQ Trigger]()
- [IF](../../core-nodes/If/README.md)
- [Vonage](../../nodes/Vonage/README.md)
- [No Operation, do nothing](../../core-nodes/NoOperationDoNothing/README.md)
The final workflow should look like the following image.
![A workflow with the RabbitMQ Trigger node](./workflow.png)
### 1. RabbitMQ Trigger node
This node will trigger the workflow when a new message is sent to the queue `temp`. If you're using a different queue, use that instead. We are sending the message `{ "id": 1, "temp": 100 }` to `temp`.
1. First of all, you'll have to enter credentials for the RabbitMQ Trigger node. You can find out how to do that [here](../../../credentials/RabbitMQ/README.md).
2. Enter the name of the queue or topic in the ***Queue / Topic*** field.
3. Click on ***Add Option*** and select 'JSON Parse Body'.
4. Toggle ***JSON Parse Body*** to `true`. By setting this value to true, the node returns the body as JSON instead of a string.
5. Click on ***Add Option*** and select 'Only Content'.
6. Toggle ***Only Content*** to `true`. By setting this to true, the node only returns the message.
7. Click on ***Execute Node*** to run the node.
In the screenshot below, you will notice that the node gets triggered when a new message is sent to the `temp` queue in RabbitMQ.
![Using the RabbitMQ Trigger node to get a message from a queue](./RabbitMQTrigger_node.png)
### 2. IF node
This node will compare the value of `temp` that we received in the message from the previous node. If the value is greater than 50, it will return true otherwise false.
::: v-pre
1. Click on ***Add Condition*** and select 'Number' from the dropdown list.
2. Click on the gears icon next to the ***Value 1*** field and click on ***Add Expression***.
3. Select the following in the ***Variable Selector*** section: Nodes > RabbitMQ > Output Data > JSON > temp. You can also add the following expression: `{{$node["RabbitMQ"].json["temp"]}}`.
4. Select 'Larger' from the ***Operation*** dropdown list.
5. Set ***Value 2*** to 50.
6. Click on ***Execute Node*** to run the node.
:::
In the screenshot below, you will notice that the node returns output for **true** when the temperature is greater than 50.
![Using the IF node to check if the temp is larger than 50](./IF_node.png)
### 3. Vonage node (send: sms)
This node sends an SMS to the specified phone number when the value of `temp` is greater than `50`.
1. Create a Vonage node connected to the 'true' output of the IF node.
2. You'll have to enter credentials for the Vonage node. You can find out how to do that [here](../../../credentials/Vonage/README.md).
3. Enter the name of the sender in the ***From*** field. If you're using a number, enter the number instead.
4. Enter the receiver's phone number in the ***To*** field.
5. Click on the gears icon next to the ***Message*** field and click on ***Add Expression***.
::: v-pre
6. Enter the following in the ***Expression*** field.
```
Alert!
The value of temp is {{$node["RabbitMQ"].json["temp"]}}.
```
7. Click on ***Execute Node*** to run the node.
:::
In the screenshot below, you will notice that the node sends an SMS with the value of `temp` that we received from the RabbitMQ Trigger node.
![Using the Vonage node to send an SMS](./Vonage_node.png)
### 4. NoOp node
Adding this node here is optional, as the absence of this node won't make a difference to the functioning of the workflow.
1. Create a ***NoOp*** node connected to the 'false' output of the IF node.
2. Click on ***Execute Node*** to run the node.
![Using the NoOp node](./NoOp_node.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB