Merge branch 'master' into update/httpRequest

This commit is contained in:
Tanay Pant 2020-12-07 09:20:42 +01:00
commit db631f8a67
12 changed files with 188 additions and 15 deletions

View File

@ -44,7 +44,7 @@ persist the data mount the `~/.n8n` folder:
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/root/.n8n \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
```
@ -93,7 +93,7 @@ If you're running n8n with Docker, start n8n with `--tunnel`
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/root/.n8n \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n \
n8n start --tunnel
```

View File

@ -122,6 +122,79 @@ Save the workflow and execute it again by clicking on the ***Execute Workflow***
This example workflow uses the Webhook 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 every time a GET request is sent to the ***Production*** webhook URL.
:::
## FAQs
### 1. Where to find the Webhook URLs?
The Webhook node has two URLs - Test URL and Production URL.
To get these URLs, follow the steps mentioned below.
1. Click on ***Webhook URLs***. By default, the node displays the Production URL.
2. If you want the Test URL, click on the ***Test*** tab.
3. To copy the URL, click on the displayed URL.
Here is a GIF demonstrating how to retrieve the test and production webhook URLs in n8n.
![Retrieving the Test and Production URLs from the Webhook node](./webhook-url.gif)
### 2. How to use the HTTP Request node to trigger the Webhook node?
The [HTTP Request](../HTTPRequest/README.md) node is used to make HTTP requests to the URL you specify. To use the HTTP Request node to trigger the Webhook node, follow the steps mentioned below.
1. Create a new workflow.
2. Add the HTTP Request node to the workflow.
3. Select the appropriate method from the ***Request Method*** dropdown list. For example, if you have selected GET as the HTTP method in your Webhook node, select GET as the request method in the HTTP Request node.
4. Copy the URL from the Webhook node, and paste it in the ***URL*** field in the HTTP Request node.
5. Execute the workflow with the Webhook node if you're using the Test URL.
6. Execute the HTTP Request node.
Here is a video demonstrating how to send a request to a Webhook based workflow using the HTTP Request node:
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/WLIDTRJGfWw" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
### 3. How to use cURL to trigger the Webhook node?
You can use [cURL](https://curl.se/) to make HTTP requests that will trigger the Webhook node. To use cURL, make sure that you have installed it on your machine. You can follow [this guide](https://www.booleanworld.com/curl-command-tutorial-examples/) to install cURL on your machine.
Based on your use-case, you can make an HTTP request with or without any parameters. You can also send files with the HTTP request using cURL.
**Note:** In the following commands, replace `https://your-n8n.url/webhook/path` with your webhook URL.
- #### Make an HTTP request without any parameters
To make a GET request without any parameters, use the following command in your terminal.
```sh
curl --request GET https://your-n8n.url/webhook/path
```
To make a POST request, use the following command.
```bash
curl --request POST https://your-n8n.url/webhook/path
```
- #### Make an HTTP request with body parameter
To make an HTTP request with a body parameter, use the following command.
```sh
curl --request GET https://your-n8n.url/webhook/path --data 'key=value'
```
- #### Make an HTTP request with header parameter
To make an HTTP request with a header parameter, use the following command.
```sh
curl --request GET https://your-n8n.url/webhook/path --header 'key=value'
```
- #### Make an HTTP request to send a file
To send a file with the HTTP request, use the following command.
```sh
curl --request GET https://your-n8n.url/webhook/path --from 'key=@/path/to/file'
```
Replace `/path/to/file` with the path of the file you want to send.
## Further Reading
- [Webhook Node — The Versatile Toolbox 🧰](https://medium.com/n8n-io/webhook-node-the-versatile-toolbox-21cb17cee862)

Binary file not shown.

After

Width:  |  Height:  |  Size: 636 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

View File

@ -22,7 +22,7 @@ You can find authentication information for this node [here](../../../credential
- Get a conversation's history of messages and events
- Invite a user to a channel
- Join an existing conversation
- Kick a user from a channel
- Remove a user from a channel
- Leave a conversation
- Open or resume a direct message or multi-person direct message
- Rename a conversation
@ -56,9 +56,10 @@ You can find authentication information for this node [here](../../../credential
## Example Usage
This workflow shows you how to post a message in a Slack channel. You can also find the [workflow](https://n8n.io/workflows/416) on this website. This example usage workflow uses the following two nodes.
- [Start](../../core-nodes/Start)
This workflow allows you to create a channel, invite users to the channel, post a message, and upload a file to the channel. You can also find the [workflow](https://n8n.io/workflows/811) on n8n.io This example usage workflow uses the following nodes.
- [Start](../../core-nodes/Start/README.md)
- [Slack]()
- [HTTP Request](../../core-nodes/HTTPRequest/README.md)
The final workflow should look like the following image.
@ -68,16 +69,109 @@ The final workflow should look like the following image.
The Start node exists by default when you create a new workflow.
### 2. Slack Node
### 2. Slack node (create: channel)
1. Click on the plus button, search for "Slack", select it and double-click on the new node.
2. Select OAuth2 in the *Authentication* field and select "Create new" in the *Slack OAuth2 API* field.
3. Create a credential as shown in [this tutorial](../../../credentials/Slack/).
4. Enter the name of the channel in the *Channel* field.
5. Enter the text of the message to be posted in *Text* field.
6. Browse the *Attachments*, *Other Options*, and *Blocks* to see if you would like to use any of them.
7. Click on *Execute Node* to run the workflow.
This node will create a new channel in your Slack workspace. This operation requires the `channel:manage` scope. Add this scope under the ***Bot Token Scopes*** section on Slack. You can refer to the [FAQs](#_2-how-to-add-oauth-scopes-to-a-slack-app) to learn how to add scopes.
1. Select 'Access Token' from the ***Authentication*** dropdown list.
2. You'll have to enter credentials for the Slack node. You can find out how to enter credentials for this node [here](../../../credentials/Slack/README.md).
3. Select 'Channel' from the ***Resource*** dropdown list.
4. Enter a channel name in the ***Channel*** field.
5. Click on ***Execute Node*** to run the node.
In the screenshot below, you will notice that node creates a new channel in Slack.
![Using the Slack node to create a channel](./Slack_node.png)
### 3. Slack1 node (invite: channel)
This node will invite a member to the channel that we created in the previous node. This operation requires the `channel:read` scope. Add this scope under the ***Bot Token Scopes*** section on Slack.
::: v-pre
1. Select 'Access Token' from the ***Authentication*** dropdown list.
2. Select the credentials that you entered in the previous node.
3. Select 'Channel' from the ***Resource*** dropdown list.
4. Select 'Invite' from the ***Operation*** dropdown list.
5. Click on the gears icon next to the ***Channel*** field click on ***Add Expression***.
6. Select the following in the ***Variable Selector*** section: Nodes > Slack > Output Data > JSON > id. You can also add the following expression: `{{$node["Slack"].json["id"]}}`.
7. Select the users from the ***User IDs*** dropdown list. The users you select in this field will be added to the channel.
8. Click on ***Execute Node*** to run the node.
:::
In the screenshot below, you will notice that node invites the user to the channel we created using the previous node.
![Using the Slack node to invite a user to a channel](./Slack1_node.png)
### 4. Slack2 node (post: message)
This node will post a message in the channel with an attachment.
::: v-pre
1. Select 'Access Token' from the ***Authentication*** dropdown list.
2. Select the credentials that you entered in the previous node.
3. Click on the gears icon next to the ***Channel*** field click on ***Add Expression***.
4. Select the following in the ***Variable Selector*** section: Nodes > Slack > Output Data > JSON > id. You can also add the following expression: `{{$node["Slack"].json["id"]}}`.
5. Enter a message in the ***Text*** field.
6. Toggle ***As User*** to `true`. This option allows you to post a message as a bot.
7. Click on the ***Add attachment*** button.
8. Select 'Image URL' from the ***Add attachment item*** dropdown list.
9. Enter the URL of an image in the ***Image URL*** field.
10. Select 'Title' from the ***Add attachment item*** dropdown list.
11. Enter a title in the ***Title*** field.
12. Click on ***Execute Node*** to run the node.
:::
In the screenshot below, you will notice that node sends a message with an attachment to the channel that we created in the previous node.
![Using the Slack node to send a message with an attachment to a channel](./Slack2_node.png)
### 5. HTTP Request node (GET)
This node will fetch a file from a URL. You can also use the [Read Binary File](../../core-nodes/ReadBinaryFile/README.md) node to read a file from the path you specify.
1. Enter the URL of a file in the ***URL*** field.
2. Select 'File' from the ***Response Format*** dropdown list.
3. Click on ***Execute Node*** to run the node.
In the screenshot below, you will notice that the HTTP Request node fetches the file from the URL. This file gets passed on as binary data to the next node in the workflow.
![Using the HTTP Request node to fetch a file from a URL](./HTTPRequest_node.png)
### 6. Slack3 node (upload: file)
This node will upload the file that we got from the previous node to a channel we specify.
1. Select 'Access Token' from the ***Authentication*** dropdown list.
2. Select the credentials that you entered in the previous Slack node.
3. Select 'File' from ***Resource*** dropdown list.
4. Select 'Upload' from the ***Operation*** dropdown list.
5. Toggle ***Binary Data*** to true.
6. Click on ***Add options*** and select 'Channels'.
7. Select the channel from the ***Channels*** dropdown list.
8. Click on ***Execute Node*** to run the node.
In the screenshot below, you will notice that the node uploads the file to the channel that we created earlier.
![Using the Slack node to upload a file to a channel](./Slack3_node.png)
## FAQs
### 1. How to create a private channel?
To create a private channel, follow the steps mentioned below.
1. Select 'Channel' from the ***Resource*** dropdown list.
2. Select 'Create' from the ***Operation*** dropdown list.
3. Click on the ***Add Field*** button.
4. Toggle ***Is Private*** to `true`.
### 2. How to add OAuth Scopes to a Slack app?
Your app needs appropriate scopes and permissions to perform actions. For example, if you want to create a new channel, your app requires the `channel:manage` scope. To add scopes and permissions, follow the steps mentioned below.
1. Navigate to the [Slack App dashboard](https://api.slack.com/apps) page and select your app.
2. Click on 'OAuth & Permissions' under the ***Feature*** section on the left sidebar.
3. Scroll down to the ***Scopes*** section.
4. If you're building a bot, click on ***Add an OAuth Scope*** under the ***Bot Token Scopes***.
5. Select the permissions you want to give to your bot from the dropdown list.
6. If you want the app to access user data and act on behalf of users that authorize them, add scopes under the ***User Token Scopes***.
7. When you add new scopes, Slack will ask you to reinstall the app. Click on 'reinstall your app' on the top of the page and reinstall the app.
You can refer to the official documentation on [Scopes and permissions](https://api.slack.com/scopes) to learn more.
## Further Reading

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 158 KiB

View File

@ -28,6 +28,13 @@ N8N_LISTEN_ADDRESS=1.1.1.1
## Base URL
::: warning 💡 Keep in mind
This variable only gets used when the `n8n-editor-ui` package gets built manually. Hence,
it does not get used in combination with the default n8n docker image. By default, `/`
gets used, meaning that it uses the root-domain.
:::
Tells the frontend how to reach the REST API of the backend.
```bash

View File

@ -133,10 +133,9 @@ services:
- N8N_PROTOCOL=https
- NODE_ENV=production
- WEBHOOK_TUNNEL_URL=https://${SUBDOMAIN}.${DOMAIN_NAME}/
- VUE_APP_URL_BASE_API=https://${SUBDOMAIN}.${DOMAIN_NAME}/
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ${DATA_FOLDER}/.n8n:/root/.n8n
- ${DATA_FOLDER}/.n8n:/home/node/.n8n
```