Skip to content

Instantly share code, notes, and snippets.

@jpoehnelt
Created December 1, 2023 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpoehnelt/b8327c11c77a3228e9f2ef1727d48a8f to your computer and use it in GitHub Desktop.
Save jpoehnelt/b8327c11c77a3228e9f2ef1727d48a8f to your computer and use it in GitHub Desktop.
{
"name": "Demo Chat App",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "e12a01b8-af4d-469f-b128-f6b504c8ffd2",
"responseMode": "responseNode",
"options": {}
},
"id": "5f63faa9-a0a8-4702-9557-2d61baec908e",
"name": "Webhook",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
840,
440
],
"webhookId": "e12a01b8-af4d-469f-b128-f6b504c8ffd2"
},
{
"parameters": {
"authentication": "serviceAccount",
"text": "={{ $json.text }}",
"translateTo": "={{ $json.language }}"
},
"id": "b50c5b6b-dfc1-43c2-bdbc-5c85e5d8f2ff",
"name": "Google Translate",
"type": "n8n-nodes-base.googleTranslate",
"typeVersion": 2,
"position": [
1520,
240
],
"credentials": {
"googleApi": {
"id": "bxUFUnMjUpmcwc9z",
"name": "Google Service Account account"
}
}
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={ \"text\": \"Translates to: '{{ $json.translatedText }}' from {{ $json.detectedSourceLanguage }}.\"}",
"options": {}
},
"id": "43a5a790-5a50-46f7-8477-187a10c9839a",
"name": "Send Translated Text",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1720,
240
]
},
{
"parameters": {
"mode": "runOnceForEachItem",
"jsCode": "$input.item.json.language = $('Switch on Event Type').item.json.body.message.argumentText.trim().split(\" \")[0];\n\n$input.item.json.text = $('Switch on Event Type').item.json.body.message.argumentText.trim().split(\" \").slice(1).join(\" \");\n\nreturn $input.item;"
},
"id": "bbdb80ce-c8e7-45dc-9a2c-207af57c7a61",
"name": "Parse Slash Command",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1320,
240
],
"notesInFlow": false,
"notes": "Parse slash commad"
},
{
"parameters": {
"respondWith": "noData",
"options": {
"responseCode": 200
}
},
"id": "cee9b28f-d709-4401-8061-21116f58654d",
"name": "Return 200",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1720,
600
]
},
{
"parameters": {
"spaceId": "={{ $json.body.space.name }}",
"messageUi": {
"text": "Thanks for adding me"
},
"additionalFields": {
"requestId": ""
}
},
"id": "6138c0d4-8567-4d14-b898-78581168b489",
"name": "Thank user for adding to space",
"type": "n8n-nodes-base.googleChat",
"typeVersion": 1,
"position": [
1320,
600
],
"notesInFlow": false,
"credentials": {
"googleApi": {
"id": "bxUFUnMjUpmcwc9z",
"name": "Google Service Account account"
}
}
},
{
"parameters": {
"dataType": "string",
"value1": "={{ $json.body.type }}",
"rules": {
"rules": [
{
"value2": "=MESSAGE",
"outputKey": "=MESSAGE"
},
{
"value2": "ADDED_TO_SPACE",
"outputKey": "ADDED_TO_SPACE"
}
]
}
},
"id": "42fd689e-3d70-4226-baf9-78c632fbde2a",
"name": "Switch on Event Type",
"type": "n8n-nodes-base.switch",
"typeVersion": 2,
"position": [
1060,
440
]
}
],
"pinData": {},
"connections": {
"Webhook": {
"main": [
[
{
"node": "Switch on Event Type",
"type": "main",
"index": 0
}
]
]
},
"Google Translate": {
"main": [
[
{
"node": "Send Translated Text",
"type": "main",
"index": 0
}
]
]
},
"Parse Slash Command": {
"main": [
[
{
"node": "Google Translate",
"type": "main",
"index": 0
}
]
]
},
"Thank user for adding to space": {
"main": [
[
{
"node": "Return 200",
"type": "main",
"index": 0
}
]
]
},
"Switch on Event Type": {
"main": [
[
{
"node": "Parse Slash Command",
"type": "main",
"index": 0
}
],
[
{
"node": "Thank user for adding to space",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"timezone": "America/Denver",
"saveManualExecutions": true,
"callerPolicy": "workflowsFromSameOwner",
"executionTimeout": -1
},
"versionId": "687c7d77-b684-4094-afb4-65fa1a590bce",
"id": "fTvbKDzX3nddsCgx",
"meta": {
"instanceId": "a080580632a3f7bf20cc570d42670426ca126ab0c44f1913c6ea86412a67d87d"
},
"tags": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment