Add new example workflows

This commit is contained in:
Harshil 2020-11-17 13:00:53 +05:30
parent f31a5cca6d
commit 69a8a9ef3a
9 changed files with 104 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 KiB

View File

@ -39,33 +39,67 @@ You can find authentication information for this node [here](../../../credential
## Example Usage
This workflow shows you how to send a message to a Telegram channel. You can also find the [workflow](https://n8n.io/workflows/451) on this website. This example usage workflow uses the following two nodes.
- [Start](../../core-nodes/Start/README.md)
This workflow allows you to send a cocktail recipe every day via a Telegram bot. You can also find the [workflow](https://n8n.io/workflows/781) on n8n.io. This example usage workflow uses the following nodes.
- [Cron](../../core-nodes/Cron/README.md)
- [HTTP Request](../../core-nodes/HTTPRequest/README.md)
- [Telegram]()
The final workflow should look like the following image.
![A workflow with the Telegram node](./workflow.png)
### 1. Cron node
### 1. Start node
The Cron node will trigger the workflow daily at 8 PM.
The Start node exists by default when you create a new workflow.
1. Click on ***Add Cron Time***.
2. Set hours to `20` in the ***Hour*** field.
3. Click on ***Execute Node*** to run the node.
### 2. Telegram node
In the screenshot below, you will notice that the Cron node is configured to trigger the workflow every day at 8 PM.
1. First of all, you'll have to enter credentials for the Telegram node. You can find out how to do that [here](../../../credentials/Telegram/README.md). Use the bot access token.
2. Add your bot to the target channel. You can find instructions on how to add a bot to a Telegram channel in the FAQs below.
3. Enter the target channel ID in *Chat ID*. You can find instructions on how to find the Chat ID in the FAQs below.
4. Write the content of your message in the *Text* field.
5. Click on *Execute Node* to run the workflow.
![Using the Cron node to trigger the workflow daily at 8 PM](./Cron_node.png)
### 2. HTTP Request node (GET)
This node will make a GET request to the API `https://www.thecocktaildb.com/api/json/v1/1/random.php` to fetch a random cocktail. This information gets passed on to the next node in the workflow.
1. Enter `https://www.thecocktaildb.com/api/json/v1/1/random.php` in the ***URL*** field.
2. 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 information of a random cocktail.
![Using the HTTP Request node to get the information about a random cocktail](./HTTPRequest_node.png)
### 3. Telegram node (sendPhoto: message)
This node will send a message on Telegram with an image and the recipe of the cocktail that we got from the previous node.
::: v-pre
1. First of all, you'll have to enter credentials for the Telegram node. You can find out how to do that [here](../../../credentials/Telegram/README.md).
2. Select 'Send Photo' from the ***Operation*** dropdown list.
3. Enter the target chat ID in the ***Chat ID*** field. Refer to the [FAQs](#how-do-i-get-a-chat-id) to know how to get the chat ID.
4. Click on the gears icon next to the ***Photo*** field and click on ***Add Expression***.
5. Select the following in the ***Variable Selector*** section: Nodes > HTTP Request > Output Data > JSON > drinks > [item: 0] > strDrinkThumb. You can also add the following expression: `{{$node["HTTP Request"].json["drinks"][0]["strDrinkThumb"]}}`.
6. Click on ***Add Field*** and select 'Caption' from the dropdown list.
7. Click on the gears icon next to the ***Caption*** field and click on ***Add Expression***.
8. Select the following in the ***Variable Selector*** section: Nodes > HTTP Request > Output Data > JSON > drinks > [item: 0] > strInstructions. You can also add the following expression: `{{$node["HTTP Request"].json["drinks"][0]["strInstructions"]}}`.
9. Click on ***Execute Node*** to run the node.
:::
In the screenshot below, you will notice that the node sends a message on Telegram with an image and the recipe of the cocktail.
![Using the Telegram node to send a message with an image and instruction of a cocktail](./Telegram_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.
:::
## FAQs
### How can I send more than 30 messages per second?
The Telegram API has a [limitation](https://core.telegram.org/bots/faq#broadcasting-to-users) to send only 30 messages per second. However, you can do the following
- [Split In Batches]() node: Use the Split in Batches node to get at most 30 chat IDs.
- [Function]() node: Use the Function node to wait for a few seconds before sending a message to the next batch of chat IDs.
The Telegram API has a [limitation](https://core.telegram.org/bots/faq#broadcasting-to-users) of sending only 30 messages per second. Follow the steps mentioned below to send more than 30 messages:
1. Split In Batches node: Use the [Split in Batches](../../core-nodes/SplitInBatches/README.md) node to get at most 30 chat IDs from your database.
2. Telegram node: Connect the Telegram node with the Split In Batches node. Use the ***Expression Editor*** to select the Chat IDs from the Split in Batches node.
3. Function node: Connect the [Function](../../core-nodes/Function/README.md) node with the Telegram node. Use the Function node to wait for a few seconds before fetching the next batch of chat IDs. Connect this node with the Split In Batches node.
You can also use this [workflow](https://n8n.io/workflows/772).
@ -81,9 +115,10 @@ You can also use this [workflow](https://n8n.io/workflows/772).
There are two ways to get the Chat ID in Telegram.
- Using the [Telegram Trigger]() node: On successful execution, the Telegram Trigger node returns a Chat ID. You can use the Telegram Trigger node in your workflow to get a Chat ID.
- Use the `@RawDataBot`: The `@RawDataBot` returns the raw data of the chat with a Chat ID. Invite the `@RawDataBot` to your channel/group, and upon joining, it will output a Chat ID along with other information. Be sure to remove the `@RawDataBot` from your group/channel afterward.
- Using the [Telegram Trigger](../../trigger-nodes/TelegramTrigger/README.md) node: On successful execution, the Telegram Trigger node returns a Chat ID. You can use the Telegram Trigger node in your workflow to get a Chat ID.
- Using the `@RawDataBot`: The `@RawDataBot` returns the raw data of the chat with a Chat ID. Invite the `@RawDataBot` to your channel/group, and upon joining, it will output a Chat ID along with other information. Be sure to remove the `@RawDataBot` from your group/channel afterward.
## Further Reading
- [Creating Telegram Bots with n8n, a No-Code Platform](https://medium.com/n8n-io/creating-telegram-bots-with-n8n-a-no-code-platform-fdf1f0928da7)
- [Automatically Adding Expense Receipts to Google Sheets with Telegram, Mindee, Twilio, and n8n 🧾](https://medium.com/n8n-io/automatically-adding-expense-receipts-to-google-sheets-with-telegram-mindee-twilio-and-n8n-c47eb2f8d7a5)

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 KiB

View File

@ -14,33 +14,73 @@ You can find authentication information for this node [here](../../../credential
## Updates
- `*`: All updates
- message: Trigger on a new incoming message of any kind- text, photo, sticker, etc
- edited_message: Trigger on a new version of a channel post that is known to the bot and was edited
- channel_post: Trigger on a new incoming channel post of any kind - text, photo, sticker, etc
- edited_channel_post: Trigger on a new version of a channel post that is known to the bot and was edited
- inline_query: Trigger on a new incoming inline query
- callback_query: Trigger on a new incoming callback query
- shipping_query: Trigger on a new incoming shipping query. Only for invoices with flexible price
- pre_checkout_query: Trigger on a new incoming pre-checkout query. Contains full information about checkout
- poll: Trigger on a new poll state. Bots receive only updates about stopped polls and polls which are sent by the bot
- ***message***: Trigger on a new incoming message of any kind- text, photo, sticker, etc
- ***edited_message***: Trigger on a new version of a channel post that is known to the bot and was edited
- ***channel_post***: Trigger on a new incoming channel post of any kind - text, photo, sticker, etc
- ***edited_channel_post***: Trigger on a new version of a channel post that is known to the bot and was edited
- ***inline_query***: Trigger on a new incoming inline query
- ***callback_query***: Trigger on a new incoming callback query
- ***shipping_query***: Trigger on a new incoming shipping query. Only for invoices with flexible price
- ***pre_checkout_query***: Trigger on a new incoming pre-checkout query. Contains full information about checkout
- ***poll***: Trigger on a new poll state. Bots receive only updates about stopped polls and polls which are sent by the bot
## Example Usage
This workflow allows you to receive updates from Telegram. You can also find the [workflow](https://n8n.io/workflows/456) on the website. This example usage workflow would use the following node.
This workflow allows you to receive updates from Telegram and send an image of a cocktail. You can also find the [workflow](https://n8n.io/workflows/456) on n8n.io. This example usage workflow would use the following nodes.
- [Telegram Trigger]()
- [HTTP Request](../../core-nodes/HTTPRequest/README.md)
- [Telegram](../../nodes/Telegram/README.md)
The final workflow should look like the following image.
![A workflow with the Telegram Trigger node](./workflow.png)
### 1. Telegram Trigger node
1. First of all, you'll have to enter credentials for the Telegram Trigger node. You can find out how to do that [here](../../../credentials/Telegram/README.md).
2. Select the `*` option in the *Updates* field to receive all updates.
3. Click on *Execute Node* to run the workflow.
This node will trigger the workflow when a user sends a new message.
1. First of all, you'll have to enter credentials for the Telegram Trigger node. You can find out how to do that [here](../../../credentials/Telegram/README.md).
2. Select 'message' from the ***Updates*** dropdown list. This will trigger the workflow when a user sends a message.
3. Click on ***Execute Node*** to run the node.
In the screenshot below, you will notice that the node triggers the workflow when a user sends a new message.
![Using the Telegram Trigger node to trigger the workflow](./TelegramTrigger_node.png)
### 2. HTTP Request node (GET)
This node will make a GET request to the API `https://www.thecocktaildb.com/api/json/v1/1/random.php` to fetch a random cocktail. This information gets passed on to the next node in the workflow.
1. Enter `https://www.thecocktaildb.com/api/json/v1/1/random.php` in the ***URL*** field.
2. 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 information of a random cocktail.
![Using the HTTP Request node to get the information about a random cocktail](./HTTPRequest_node.png)
### 3. Telegram node (sendPhoto: message)
This node will send a reply to the message with the name and image of the cocktail that we got from the previous node.
::: v-pre
1. Select the credentials that you entered in the Telegram Trigger node.
2. Select 'Send Photo' from the ***Operation*** dropdown list.
3. Click on the gears icon next to the ***Chat ID*** field and click on ***Add Expression***.
4. Select the following in the ***Variable Selector*** section: Nodes > Telegram Trigger > Output Data > JSON > message > chat > id. You can also add the following expression: `{{$node["Telegram Trigger"].json["message"]["chat"]["id"]}}`.
5. Click on the gears icon next to the ***Photo*** field and click on ***Add Expression***.
6. Select the following in the ***Variable Selector*** section: Nodes > HTTP Request > Output Data > JSON > drinks > [item: 0] > strDrinkThumb. You can also add the following expression: `{{$node["HTTP Request"].json["drinks"][0]["strDrinkThumb"]}}`.
7. Click on ***Add Field*** and select 'Caption' from the dropdown list.
8. Click on the gears icon next to the ***Caption*** field and click on ***Add Expression***.
9. Select the following in the ***Variable Selector*** section: Nodes > HTTP Request > Output Data > JSON > drinks > [item: 0] > strDrink. You can also add the following expression: `{{$node["HTTP Request"].json["drinks"][0]["strDrink"]}}`.
10. Click on ***Add Field*** and select 'Reply To Message ID' from the dropdown list.
11. Click on the gears icon next to the ***Reply To Message ID*** field and click on ***Add Expression***.
12. Select the following in the ***Variable Selector*** section: Nodes > Telegram Trigger > Output Data > JSON > message > message_id. You can also add the following expression: `{{$node["Telegram Trigger"].json["message"]["message_id"]}}`.
13. Click on ***Execute Node*** to run the node.
:::
In the screenshot below, you will notice that the node sends a reply to the message with the name and image of the cocktail that we got from the previous node.
![Using the Telegram node to send a message with an image and instruction of a cocktail](./Telegram_node.png)
## Further Reading
- [Creating Telegram Bots with n8n, a No-Code Platform](https://medium.com/n8n-io/creating-telegram-bots-with-n8n-a-no-code-platform-fdf1f0928da7)
- [Automatically Adding Expense Receipts to Google Sheets with Telegram, Mindee, Twilio, and n8n 🧾](https://medium.com/n8n-io/automatically-adding-expense-receipts-to-google-sheets-with-telegram-mindee-twilio-and-n8n-c47eb2f8d7a5)

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB