Skip to content

Commit cb22ea8

Browse files
author
Deborah
authored
Merge pull request n8n-io#2199 from n8n-io/DOC-931-template-list
templates widget
2 parents 8a1208d + 7efa82a commit cb22ea8

File tree

10 files changed

+92
-25
lines changed

10 files changed

+92
-25
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.n8n-templates-widget {
2+
display: flex;
3+
flex-direction: column;
4+
}
5+
6+
.n8n-templates-widget-template {
7+
display: flex;
8+
flex-direction: column;
9+
border: .05rem solid var(--md-default-fg-color--lightest);
10+
border-radius: 6px;
11+
margin: .4em;
12+
padding: 12px 16px;
13+
}
14+
15+
.n8n-templates-name {
16+
margin-top: 0px;
17+
margin-bottom: 24px;
18+
font-size: 15px;
19+
}
20+
21+
.n8n-templates-widget-more {
22+
padding: 1em 0 0 0;
23+
}
24+
25+
.n8n-templates-link {
26+
font-weight: 600;
27+
font-size: 15px;
28+
}

docs/integrations/builtin/app-nodes/n8n-nodes-base.asana.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,8 @@ Due to changes in Asana's API, some operations in this node stopped working on 1
5555
* Get a user
5656
* Get all users
5757

58+
5859
--8<-- "_snippets/integrations/builtin/app-nodes/operation-not-supported.md"
5960

61+
62+

docs/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
---
22
#https://www.notion.so/n8n/Frontmatter-432c2b8dff1f43d4b1c8d20075510fe4
3-
title: Agent
3+
title: AI Agent
44
description: Documentation for the Agent node in n8n, a workflow automation platform. Includes details of operations and configuration, and links to examples and credentials information.
55
---
66

7-
# Agent
7+
# AI Agent
8+
9+
810

911
Use the Agent node to set which agent type you want to use.
1012

1113
On this page, you'll find the node parameters for the Agent node, and links to more resources.
1214

13-
/// note | Examples and templates
14-
For usage examples and templates to help you get started, refer to n8n's [Agent integrations](https://n8n.io/integrations/agent/){:target=_blank .external-link} page.
15-
///
16-
1715
/// note | Connect a tool
1816
You must connect at least one tool sub-node.
1917
///
@@ -207,9 +205,11 @@ The input from the chat. This is the user's query, also known as the prompt.
207205

208206
--8<-- "_snippets/integrations/builtin/cluster-nodes/langchain-root-nodes/return-intermediate-steps.md"
209207

210-
## Related resources
208+
## Templates and examples
209+
210+
[[ templatesWidget(title, page) ]]
211211

212-
View [example workflows and related content](https://n8n.io/integrations/agent/){:target=_blank .external-link} on n8n's website.
212+
## Related resources
213213

214214
Refer to [LangChain's documentation on agents](https://js.langchain.com/docs/modules/agents/agent_types/){:target=_blank .external-link} for more information about the service.
215215

docs/integrations/builtin/core-nodes/n8n-nodes-base.aggregate.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ For usage examples and templates to help you get started, refer to n8n's [Aggreg
3131
* **Options** > **Add Field**: use this to add the setting:
3232
* **Include Binaries**: include binary data from the input in the new output.
3333

34+
35+
3436
## Related resources
3537

3638
View [example workflows and related content](https://n8n.io/integrations/aggregate/){:target=_blank .external-link} on n8n's website.

document-templates/app-nodes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ On this page, you'll find a list of operations the _Name_ node supports, and lin
3939
You can find authentication information for this node [here](/integrations/builtin/credentials/_Name_/).
4040
///
4141

42-
/// note | Examples and templates
43-
For usage examples and templates to help you get started, refer to n8n's [_Name_'s integrations](https://n8n.io/integrations/_Name_/){:target=_blank .external-link} page.
44-
///
4542

4643
## Operations
4744

4845
* _Bullet list_
4946
* _Of available operations_.
5047

48+
## Templates and examples
49+
50+
<!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
51+
[[ templatesWidget(title, page) ]]
52+
5153
## Related resources
5254

5355
<!-- provide a link to the trigger node docs, if there is a trigger node for this service -->
5456
n8n provides a trigger node for _Name_. You can find the trigger node docs [here](/integrations/builtin/trigger-nodes/n8n-nodes-base._Name_trigger/).
5557

56-
<!-- add a link to the node page on n8n's website. For example: https://n8n.io/integrations/356-gmail/ -->
57-
View [example workflows and related content](https://n8n.io/integrations/_slug_/){:target=_blank .external-link} on n8n's website.
5858

5959
<!-- add a link to the service's documentation. This should usually go direct to the API docs -->
6060
Refer to [_Name_'s documentation](){:target=_blank .external-link} for more information about the service.

document-templates/cluster-nodes.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ On this page, you'll find a list of operations the _Name_ node supports, and lin
1616
/// note | Credentials
1717
You can find authentication information for this node [here](/integrations/builtin/credentials/_Name_/).
1818
///
19-
/// note | Examples and templates
20-
For usage examples and templates to help you get started, refer to n8n's [_Name_'s integrations](https://n8n.io/integrations/_Name_/){:target=_blank .external-link} page.
21-
///
19+
2220
## Node parameters
2321

2422
* _Bullet list_
2523
* _Of available operations_.
2624

25+
## Templates and examples
26+
27+
<!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
28+
[[ templatesWidget(title, page) ]]
29+
2730
## Related resources
2831

29-
View [example workflows and related content](https://n8n.io/integrations/_Name_/){:target=_blank .external-link} on n8n's website.
3032

3133
Refer to [_Name_'s documentation](){:target=_blank .external-link} for more information about the service.

document-templates/core-nodes.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ _Briefly summarize the functionality._
3232
You can find authentication information for this node [here](/integrations/builtin/credentials/_Name_/).
3333
///
3434

35-
/// note | Examples and templates
36-
For usage examples and templates to help you get started, refer to n8n's [_Name_ integrations](https://n8n.io/integrations/_Name_/){:target=_blank .external-link} page.
37-
///
35+
3836

3937
## Node parameters
4038

@@ -47,4 +45,9 @@ You should include: quirks, pain points, complex topics that trip people up
4745
You should not include: basic usage examples
4846
-->
4947

48+
## Templates and examples
49+
50+
<!-- see https://www.notion.so/n8n/Pull-in-templates-for-the-integrations-pages-37c716837b804d30a33b47475f6e3780 -->
51+
[[ templatesWidget(title, page) ]]
52+
5053

document-templates/trigger-nodes.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ On this page, you'll find a list of events the _Name_ trigger node can respond t
3939
/// note | Credentials
4040
You can find authentication information for this node [here](/integrations/builtin/credentials/_Name_/).
4141
///
42-
/// note | Examples and templates
43-
For usage examples and templates to help you get started, refer to n8n's [_Name_ integrations](https://n8n.io/integrations/_Name_/){:target=_blank .external-link} page.
44-
///
42+
4543
## Events
4644

4745
* _Bullet list_

main.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
11
import requests
2-
import urllib.parse
32
import json
3+
import re
4+
import traceback
5+
import urllib.parse
46

57
def define_env(env):
68

7-
@env.macro
9+
@env.macro
10+
def templatesWidget(title, page):
11+
node_for_template = title.replace(' ', '+')
12+
getLastBitOfUrl = re.search("(\.)(.*)(\/)$", page.abs_url)
13+
node_for_integrations_slug = getLastBitOfUrl.group(2)
14+
response = requests.get(url = f'https://api.n8n.io/api/templates/search?rows=3&search=&category=&apps={node_for_template}&page=1&sort=views:desc')
15+
data = response.json()
16+
# not all nodes have three templates
17+
try:
18+
workflows = data["workflows"][:3]
19+
workflow_one, workflow_two, workflow_three = workflows
20+
except:
21+
return f'<span class="n8n-templates-widget-more"><a href="https://n8n.io/integrations/{node_for_integrations_slug}/" target="_blank">Browse {title} integration templates</a>, or <a href="https://n8n.io/workflows/" target="_blank">search all templates</a></span>'
22+
# the data is not trustworthy
23+
try:
24+
workflow_one_title = workflow_one["name"]
25+
workflow_one_user = workflow_one["user"]["name"]
26+
workflow_one_url = f'https://n8n.io/workflows/{workflow_one["id"]}-{workflow_one["name"].lower().replace(" ", "-").replace(":", "")}/'
27+
workflow_two_title = workflow_two["name"]
28+
workflow_two_user = workflow_two["user"]["name"]
29+
workflow_two_url = f'https://n8n.io/workflows/{workflow_two["id"]}-{workflow_two["name"].lower().replace(" ", "-").replace(":", "")}/'
30+
workflow_three_title = workflow_three["name"]
31+
workflow_three_url = f'https://n8n.io/workflows/{workflow_three["id"]}-{workflow_three["name"].lower().replace(" ", "-").replace(":", "")}/'
32+
workflow_three_user = workflow_three["user"]["name"]
33+
except:
34+
return f'<span class="n8n-templates-widget-more"><a href="https://n8n.io/integrations/{node_for_integrations_slug}/" target="_blank">Browse all {title} integration templates</a>, or <a href="https://n8n.io/workflows/" target="_blank">search all templates</a></span>'
35+
36+
return f'<div class="n8n-templates-widget"><div class="n8n-templates-widget-template"><strong>{workflow_one_title}</strong><p class="n8n-templates-name">by {workflow_one_user}</p><a class="n8n-templates-link" href="{workflow_one_url}" target="_blank">View template details</a></div><div class="n8n-templates-widget-template"><strong>{workflow_two_title}</strong><p class="n8n-templates-name">by {workflow_two_user}</p><a class="n8n-templates-link" href="{workflow_two_url}" target="_blank">View template details</a></div><div class="n8n-templates-widget-template"><strong>{workflow_three_title}</strong><p class="n8n-templates-name">by {workflow_three_user}</p><a class="n8n-templates-link" href="{workflow_three_url}" target="_blank">View template details</a></div><span class="n8n-templates-widget-more"><a href="https://n8n.io/integrations/{node_for_integrations_slug}/" target="_blank">Browse {title} integration templates</a>, or <a href="https://n8n.io/workflows/" target="_blank">search all templates</a></span></div>'
37+
838
def workflowDemo(workflow_endpoint):
939
r = requests.get(url = workflow_endpoint)
1040
wf_data = r.json()

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ extra:
8282
extra_css:
8383
- _extra/css/extra.css
8484
- _extra/css/macro-styles.css
85+
- _extra/css/templates-widget.css
8586
- _extra/css/workflow-demo.css
8687
# https://squidfunk.github.io/mkdocs-material/customization/?h=#additional-javascript
8788
extra_javascript:

0 commit comments

Comments
 (0)