Skip to content

Instantly share code, notes, and snippets.

@richardsondx
Last active June 21, 2025 05:38
Show Gist options
  • Save richardsondx/706d217f2999955b5eb905f7d8c78c73 to your computer and use it in GitHub Desktop.
Save richardsondx/706d217f2999955b5eb905f7d8c78c73 to your computer and use it in GitHub Desktop.
Generate an n8n workflow with a switch node that based on the language I've chosen translate sentence manually send for me with openai
{
"id": "workflow-1df07090",
"meta": {
"instanceId": "63e84bfb",
"templateCredsSetupCompleted": false
},
"name": "Generated Workflow",
"nodes": [
{
"id": "manual_trigger",
"parameters": {},
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
100,
300
]
},
{
"id": "set_language",
"parameters": {
"assignments": {
"assignments": [
{
"id": "language_setting",
"name": "language",
"type": "string",
"value": "English"
},
{
"id": "sentence_setting",
"name": "sentence",
"type": "string",
"value": "Hello, how are you?"
}
]
}
},
"name": "Set Language",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
300,
300
]
},
{
"id": "switch_language",
"parameters": {
"rules": {
"values": [
{
"outputKey": "spanish",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "language_condition_1",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.language }}",
"rightValue": "Spanish"
}
]
},
"renameOutput": true
},
{
"outputKey": "french",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "language_condition_2",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.language }}",
"rightValue": "French"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"name": "Switch Language",
"type": "n8n-nodes-base.switch",
"typeVersion": 3.2,
"position": [
500,
300
]
},
{
"id": "openai_translate_spanish",
"parameters": {
"prompt": "Translate the following sentence to Spanish: {{ $json.sentence }}",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
}
},
"name": "Translate to Spanish",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1,
"position": [
700,
200
]
},
{
"id": "openai_translate_french",
"parameters": {
"prompt": "Translate the following sentence to French: {{ $json.sentence }}",
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini",
"cachedResultName": "GPT-4O-MINI"
}
},
"name": "Translate to French",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1,
"position": [
700,
400
]
},
{
"id": "set_translated_spanish",
"parameters": {
"assignments": {
"assignments": [
{
"id": "translated_spanish_setting",
"name": "translatedSentence",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"name": "Set Translated Spanish",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
900,
200
]
},
{
"id": "set_translated_french",
"parameters": {
"assignments": {
"assignments": [
{
"id": "translated_french_setting",
"name": "translatedSentence",
"type": "string",
"value": "={{ $json.text }}"
}
]
}
},
"name": "Set Translated French",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
900,
400
]
},
{
"id": "send_email",
"parameters": {
"text": "={{ $json.translatedSentence }}",
"subject": "Translated Sentence",
"toEmail": "[email protected]",
"fromEmail": "[email protected]"
},
"name": "Send Email",
"type": "n8n-nodes-base.emailSend",
"typeVersion": 2.1,
"position": [
1100,
300
]
}
],
"connections": {
"Set Language": {
"main": [
[
{
"node": "Switch Language",
"type": "main",
"index": 0
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Set Language",
"type": "main",
"index": 0
}
]
]
},
"Switch Language": {
"main": [
[
{
"node": "Translate to Spanish",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to French",
"type": "main",
"index": 0
}
]
]
},
"Set Translated French": {
"main": [
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
]
]
},
"Set Translated Spanish": {
"main": [
[
{
"node": "Send Email",
"type": "main",
"index": 0
}
]
]
},
"Translate to French": {
"main": [
[
{
"node": "Set Translated French",
"type": "main",
"index": 0
}
]
]
},
"Translate to Spanish": {
"main": [
[
{
"node": "Set Translated Spanish",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"saveExecutionProgress": false
},
"staticData": {},
"tags": [],
"triggerCount": 0,
"updatedAt": "2025-06-19T06:20:53.111Z",
"versionId": "1"
}
{
"nodes": [
{
"id": "manualTrigger",
"parameters": {},
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [250, 300]
},
{
"id": "setInput",
"parameters": {
"values": {
"string": [
{ "name": "language", "value": "French" },
{ "name": "sentence", "value": "Hello, how are you?" }
]
},
"options": {}
},
"name": "Set Language + Sentence",
"type": "n8n-nodes-base.set",
"typeVersion": 2,
"position": [450, 300]
},
{
"id": "switchLanguage",
"parameters": {
"switches": [
{ "value1": "={{$json[\"language\"]}}", "value2": "French" },
{ "value1": "={{$json[\"language\"]}}", "value2": "Spanish" },
{ "value1": "={{$json[\"language\"]}}", "value2": "Japanese" }
]
},
"name": "Switch Language",
"type": "n8n-nodes-base.switch",
"typeVersion": 1,
"position": [650, 300]
},
{
"id": "openaiFrench",
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate this to French: {{$json[\"sentence\"]}}"
}
]
},
"name": "Translate to French",
"type": "n8n-nodes-base.openaiChat",
"typeVersion": 1,
"position": [850, 100]
},
{
"id": "openaiSpanish",
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate this to Spanish: {{$json[\"sentence\"]}}"
}
]
},
"name": "Translate to Spanish",
"type": "n8n-nodes-base.openaiChat",
"typeVersion": 1,
"position": [850, 300]
},
{
"id": "openaiJapanese",
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate this to Japanese: {{$json[\"sentence\"]}}"
}
]
},
"name": "Translate to Japanese",
"type": "n8n-nodes-base.openaiChat",
"typeVersion": 1,
"position": [850, 500]
}
],
"connections": {
"manualTrigger": {
"main": [["setInput"]]
},
"setInput": {
"main": [["switchLanguage"]]
},
"switchLanguage": {
"main": [
["openaiFrench"],
["openaiSpanish"],
["openaiJapanese"]
]
}
}
}
{
"name": "Language Translation with OpenAI",
"nodes": [
{
"parameters": {
"formTitle": "Translate Text",
"formDescription": "Enter a sentence and select the target language for translation",
"formFields": {
"values": [
{
"fieldLabel": "Text to Translate",
"fieldType": "string",
"name": "textToTranslate",
"requiredField": true
},
{
"fieldLabel": "Target Language",
"fieldType": "options",
"name": "targetLanguage",
"requiredField": true,
"fieldOptions": {
"values": [
{
"option": "Spanish"
},
{
"option": "French"
},
{
"option": "German"
},
{
"option": "Italian"
},
{
"option": "Portuguese"
},
{
"option": "Japanese"
},
{
"option": "Chinese (Simplified)"
},
{
"option": "Korean"
},
{
"option": "Arabic"
},
{
"option": "Russian"
}
]
}
}
]
},
"options": {}
},
"id": "manual-trigger",
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"dataType": "string",
"value1": "={{ $json.targetLanguage }}",
"rules": {
"rules": [
{
"value2": "Spanish",
"output": 0
},
{
"value2": "French",
"output": 1
},
{
"value2": "German",
"output": 2
},
{
"value2": "Italian",
"output": 3
},
{
"value2": "Portuguese",
"output": 4
},
{
"value2": "Japanese",
"output": 5
},
{
"value2": "Chinese (Simplified)",
"output": 6
},
{
"value2": "Korean",
"output": 7
},
{
"value2": "Arabic",
"output": 8
},
{
"value2": "Russian",
"output": 9
}
]
},
"fallbackOutput": "none"
},
"id": "switch-language",
"name": "Switch Language",
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"position": [
450,
300
]
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Spanish. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-spanish",
"name": "Translate to Spanish",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
50
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to French. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-french",
"name": "Translate to French",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
150
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to German. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-german",
"name": "Translate to German",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
250
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Italian. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-italian",
"name": "Translate to Italian",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
350
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Portuguese. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-portuguese",
"name": "Translate to Portuguese",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
450
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Japanese. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-japanese",
"name": "Translate to Japanese",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
550
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Simplified Chinese. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-chinese",
"name": "Translate to Chinese",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
650
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Korean. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-korean",
"name": "Translate to Korean",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
750
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Arabic. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-arabic",
"name": "Translate to Arabic",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
850
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "gpt-4",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the following text to Russian. Provide only the translation without any explanations or additional text."
},
{
"role": "user",
"content": "={{ $('manual-trigger').item.json.textToTranslate }}"
}
]
}
},
"id": "openai-russian",
"name": "Translate to Russian",
"type": "@n8n/n8n-nodes-langchain.openAi",
"typeVersion": 1.4,
"position": [
700,
950
],
"credentials": {
"openAiApi": {
"id": "1",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"values": {
"string": [
{
"name": "originalText",
"value": "={{ $('manual-trigger').item.json.textToTranslate }}"
},
{
"name": "targetLanguage",
"value": "={{ $('manual-trigger').item.json.targetLanguage }}"
},
{
"name": "translatedText",
"value": "={{ $json.choices[0].message.content }}"
}
]
},
"options": {}
},
"id": "set-output",
"name": "Format Output",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
950,
500
]
}
],
"connections": {
"manual-trigger": {
"main": [
[
{
"node": "switch-language",
"type": "main",
"index": 0
}
]
]
},
"switch-language": {
"main": [
[
{
"node": "openai-spanish",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-french",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-german",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-italian",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-portuguese",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-japanese",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-chinese",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-korean",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-arabic",
"type": "main",
"index": 0
}
],
[
{
"node": "openai-russian",
"type": "main",
"index": 0
}
]
]
},
"openai-spanish": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-french": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-german": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-italian": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-portuguese": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-japanese": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-chinese": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-korean": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-arabic": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
},
"openai-russian": {
"main": [
[
{
"node": "set-output",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "1.0.0",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "language-translation-workflow"
},
"id": "language-translation-001",
"tags": []
}
{
"name": "Language Translation Workflow",
"nodes": [
{
"parameters": {
"options": {}
},
"id": "start-node",
"name": "Manual Trigger",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "sentence",
"value": "Hello, how are you today?"
},
{
"name": "target_language",
"value": "spanish"
}
]
},
"options": {}
},
"id": "set-input-data",
"name": "Set Input Data",
"type": "n8n-nodes-base.set",
"typeVersion": 3,
"position": [
460,
300
]
},
{
"parameters": {
"dataType": "string",
"value1": "={{ $json.target_language }}",
"rules": {
"rules": [
{
"value2": "spanish",
"output": 0
},
{
"value2": "french",
"output": 1
},
{
"value2": "german",
"output": 2
},
{
"value2": "italian",
"output": 3
},
{
"value2": "portuguese",
"output": 4
},
{
"value2": "japanese",
"output": 5
},
{
"value2": "chinese",
"output": 6
},
{
"value2": "korean",
"output": 7
}
]
},
"fallbackOutput": 8
},
"id": "language-switch",
"name": "Language Switch",
"type": "n8n-nodes-base.switch",
"typeVersion": 3,
"position": [
680,
300
]
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to Spanish. Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-spanish",
"name": "Translate to Spanish",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
100
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to French. Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-french",
"name": "Translate to French",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
200
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to German. Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-german",
"name": "Translate to German",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
300
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to Italian. Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-italian",
"name": "Translate to Italian",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
400
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to Portuguese. Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-portuguese",
"name": "Translate to Portuguese",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
500
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to Japanese. Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-japanese",
"name": "Translate to Japanese",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
600
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to Chinese (Simplified). Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-chinese",
"name": "Translate to Chinese",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
700
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Translate the given text to Korean. Only return the translation, no explanations."
},
{
"role": "user",
"content": "={{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-korean",
"name": "Translate to Korean",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
800
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"resource": "chat",
"operation": "create",
"model": "gpt-3.5-turbo",
"messages": {
"values": [
{
"role": "system",
"content": "You are a professional translator. Please translate the given text to the requested language. Only return the translation, no explanations."
},
{
"role": "user",
"content": "Translate this to {{ $json.target_language }}: {{ $json.sentence }}"
}
]
},
"options": {
"temperature": 0.3,
"maxTokens": 150
}
},
"id": "translate-fallback",
"name": "Translate (Fallback)",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
900,
900
],
"credentials": {
"openAiApi": {
"id": "openai-credentials",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"values": {
"string": [
{
"name": "original_sentence",
"value": "={{ $('Set Input Data').item.json.sentence }}"
},
{
"name": "target_language",
"value": "={{ $('Set Input Data').item.json.target_language }}"
},
{
"name": "translated_text",
"value": "={{ $json.choices[0].message.content }}"
}
]
},
"options": {}
},
"id": "format-output",
"name": "Format Output",
"type": "n8n-nodes-base.set",
"typeVersion": 3,
"position": [
1120,
450
]
}
],
"connections": {
"Manual Trigger": {
"main": [
[
{
"node": "Set Input Data",
"type": "main",
"index": 0
}
]
]
},
"Set Input Data": {
"main": [
[
{
"node": "Language Switch",
"type": "main",
"index": 0
}
]
]
},
"Language Switch": {
"main": [
[
{
"node": "Translate to Spanish",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to French",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to German",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to Italian",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to Portuguese",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to Japanese",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to Chinese",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to Korean",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate (Fallback)",
"type": "main",
"index": 0
}
]
]
},
"Translate to Spanish": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate to French": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate to German": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate to Italian": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate to Portuguese": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate to Japanese": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate to Chinese": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate to Korean": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
},
"Translate (Fallback)": {
"main": [
[
{
"node": "Format Output",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "1",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "translation-workflow",
"tags": []
}
{
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"id": "a1b2c3d4-e5f6-7890-1234-567890abcdef"
},
{
"parameters": {
"fields": [
{
"name": "sentence",
"type": "string",
"label": "Sentence to Translate",
"required": true
},
{
"name": "targetLanguage",
"type": "options",
"label": "Target Language",
"options": [
{
"name": "English",
"value": "English"
},
{
"name": "Spanish",
"value": "Spanish"
},
{
"name": "French",
"value": "French"
},
{
"name": "German",
"value": "German"
},
{
"name": "Italian",
"value": "Italian"
},
{
"name": "Japanese",
"value": "Japanese"
},
{
"name": "Chinese (Simplified)",
"value": "Chinese (Simplified)"
}
],
"default": "English",
"required": true
}
],
"schema": {
"properties": {
"sentence": {
"type": "string",
"title": "Sentence to Translate"
},
"targetLanguage": {
"type": "string",
"title": "Target Language"
}
},
"type": "object"
},
"displayNode": "return",
"description": "Enter the sentence you want to translate and choose the target language."
},
"name": "Ask for Input",
"type": "n8n-nodes-base.prompt",
"typeVersion": 1,
"id": "b2c3d4e5-f6a7-8901-2345-67890abcdef0"
},
{
"parameters": {
"mode": "json",
"value": "={{$json.targetLanguage}}",
"cases": [
{
"value": "English",
"return": "English"
},
{
"value": "Spanish",
"return": "Spanish"
},
{
"value": "French",
"return": "French"
},
{
"value": "German",
"return": "German"
},
{
"value": "Italian",
"return": "Italian"
},
{
"value": "Japanese",
"return": "Japanese"
},
{
"value": "Chinese (Simplified)",
"return": "Chinese (Simplified)"
}
]
},
"name": "Switch on Language",
"type": "n8n-nodes-base.switch",
"typeVersion": 1,
"id": "c3d4e5f6-a7b8-9012-3456-7890abcdef01"
},
{
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate the following sentence to English: \"{{ $json.sentence }}\""
}
],
"authentication": "apiKey"
},
"name": "Translate to English",
"type": "n8n-nodes-base.openAiChatCompletion",
"typeVersion": 1,
"id": "d4e5f6a7-b8c9-0123-4567-890abcdef02"
},
{
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate the following sentence to Spanish: \"{{ $json.sentence }}\""
}
],
"authentication": "apiKey"
},
"name": "Translate to Spanish",
"type": "n8n-nodes-base.openAiChatCompletion",
"typeVersion": 1,
"id": "e5f6a7b8-c9d0-1234-5678-90abcdef03"
},
{
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate the following sentence to French: \"{{ $json.sentence }}\""
}
],
"authentication": "apiKey"
},
"name": "Translate to French",
"type": "n8n-nodes-base.openAiChatCompletion",
"typeVersion": 1,
"id": "f6a7b8c9-d0e1-2345-6789-0abcdef04"
},
{
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate the following sentence to German: \"{{ $json.sentence }}\""
}
],
"authentication": "apiKey"
},
"name": "Translate to German",
"type": "n8n-nodes-base.openAiChatCompletion",
"typeVersion": 1,
"id": "a7b8c9d0-e1f2-3456-7890-abcdef05"
},
{
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate the following sentence to Italian: \"{{ $json.sentence }}\""
}
],
"authentication": "apiKey"
},
"name": "Translate to Italian",
"type": "n8n-nodes-base.openAiChatCompletion",
"typeVersion": 1,
"id": "b8c9d0e1-f2a3-4567-8901-bcdef06"
},
{
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate the following sentence to Japanese: \"{{ $json.sentence }}\""
}
],
"authentication": "apiKey"
},
"name": "Translate to Japanese",
"type": "n8n-nodes-base.openAiChatCompletion",
"typeVersion": 1,
"id": "c9d0e1f2-a3b4-5678-9012-cdef07"
},
{
"parameters": {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "user",
"content": "Translate the following sentence to Chinese (Simplified): \"{{ $json.sentence }}\""
}
],
"authentication": "apiKey"
},
"name": "Translate to Chinese (Simplified)",
"type": "n8n-nodes-base.openAiChatCompletion",
"typeVersion": 1,
"id": "d0e1f2a3-b4c5-6789-0123-def08"
},
{
"parameters": {
"values": {
"result": "={{ $json.choices[0].message.content }}"
}
},
"name": "Output Translated Text",
"type": "n8n-nodes-base.return",
"typeVersion": 1,
"id": "e1f2a3b4-c5d6-7890-1234-ef09"
}
],
"connections": [
{
"from": "Start",
"to": "Ask for Input"
},
{
"from": "Ask for Input",
"to": "Switch on Language"
},
{
"from": "Switch on Language",
"to": "Translate to English",
"fromHandle": "English"
},
{
"from": "Switch on Language",
"to": "Translate to Spanish",
"fromHandle": "Spanish"
},
{
"from": "Switch on Language",
"to": "Translate to French",
"fromHandle": "French"
},
{
"from": "Switch on Language",
"to": "Translate to German",
"fromHandle": "German"
},
{
"from": "Switch on Language",
"to": "Translate to Italian",
"fromHandle": "Italian"
},
{
"from": "Switch on Language",
"to": "Translate to Japanese",
"fromHandle": "Japanese"
},
{
"from": "Switch on Language",
"to": "Translate to Chinese (Simplified)",
"fromHandle": "Chinese (Simplified)"
},
{
"from": "Translate to English",
"to": "Output Translated Text"
},
{
"from": "Translate to Spanish",
"to": "Output Translated Text"
},
{
"from": "Translate to French",
"to": "Output Translated Text"
},
{
"from": "Translate to German",
"to": "Output Translated Text"
},
{
"from": "Translate to Italian",
"to": "Output Translated Text"
},
{
"from": "Translate to Japanese",
"to": "Output Translated Text"
},
{
"from": "Translate to Chinese (Simplified)",
"to": "Output Translated Text"
}
]
}
{
"name": "Language Translation with OpenAI",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
250,
300
]
},
{
"parameters": {
"values": {
"string": [
{
"name": "sentence",
"value": "Hello, how are you?"
},
{
"name": "language",
"value": "Spanish"
}
]
},
"options": {}
},
"name": "Set Input",
"type": "n8n-nodes-base.set",
"typeVersion": 1,
"position": [
450,
300
]
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{$json.language}}",
"operation": "equal",
"value2": "Spanish"
},
{
"value1": "={{$json.language}}",
"operation": "equal",
"value2": "French"
},
{
"value1": "={{$json.language}}",
"operation": "equal",
"value2": "German"
}
]
}
},
"name": "Switch Language",
"type": "n8n-nodes-base.switch",
"typeVersion": 1,
"position": [
650,
300
]
},
{
"parameters": {
"model": "text-davinci-003",
"prompt": "=Translate the following text to Spanish: {{$json.sentence}}"
},
"name": "Translate to Spanish",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
850,
200
],
"credentials": {
"openAiApi": {
"id": "YOUR_OPENAI_API_CREDENTIALS_ID",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "text-davinci-003",
"prompt": "=Translate the following text to French: {{$json.sentence}}"
},
"name": "Translate to French",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
850,
300
],
"credentials": {
"openAiApi": {
"id": "YOUR_OPENAI_API_CREDENTIALS_ID",
"name": "OpenAI API"
}
}
},
{
"parameters": {
"model": "text-davinci-003",
"prompt": "=Translate the following text to German: {{$json.sentence}}"
},
"name": "Translate to German",
"type": "n8n-nodes-base.openAi",
"typeVersion": 1,
"position": [
850,
400
],
"credentials": {
"openAiApi": {
"id": "YOUR_OPENAI_API_CREDENTIALS_ID",
"name": "OpenAI API"
}
}
}
],
"connections": {
"Start": {
"main": [
[
{
"node": "Set Input",
"type": "main",
"index": 0
}
]
]
},
"Set Input": {
"main": [
[
{
"node": "Switch Language",
"type": "main",
"index": 0
}
]
]
},
"Switch Language": {
"main": [
[
{
"node": "Translate to Spanish",
"type": "main",
"index": 0
}
],
[
{
"node": "Translate to French",
"type": "main",
"index": 1
}
],
[
{
"node": "Translate to German",
"type": "main",
"index": 2
}
]
]
}
}
}
{
"version": 1,
"nodes": [
{
"id": "1",
"type": "n8n-nodes-base.manualTrigger",
"name": "Manual Trigger",
"typeVersion": 1,
"position": [240, 300]
},
{
"id": "2",
"type": "n8n-nodes-base.set",
"name": "Set Input",
"typeVersion": 2,
"position": [460, 300],
"parameters": {
"values": {
"string": [
{ "name": "sentence", "value": "Hola, ¿cómo estás?" },
{ "name": "target_lang", "value": "French" }
]
}
}
},
{
"id": "3",
"type": "n8n-nodes-base.switch",
"name": "Choose Language",
"typeVersion": 2,
"position": [700, 300],
"parameters": {
"property": "={{ $json[\"target_lang\"] }}",
"rules": [
{ "value": "Spanish" },
{ "value": "French" },
{ "value": "German" }
]
}
},
{
"id": "4",
"type": "n8n-nodes-base.openai",
"name": "Translate to Spanish",
"typeVersion": 2,
"position": [960, 140],
"parameters": {
"model": "gpt-4o-mini",
"prompt": "Translate the following text to Spanish:\n\n{{ $json[\"sentence\"] }}",
"responseFormat": "json"
}
},
{
"id": "5",
"type": "n8n-nodes-base.openai",
"name": "Translate to French",
"typeVersion": 2,
"position": [960, 300],
"parameters": {
"model": "gpt-4o-mini",
"prompt": "Translate the following text to French:\n\n{{ $json[\"sentence\"] }}",
"responseFormat": "json"
}
},
{
"id": "6",
"type": "n8n-nodes-base.openai",
"name": "Translate to German",
"typeVersion": 2,
"position": [960, 460],
"parameters": {
"model": "gpt-4o-mini",
"prompt": "Translate the following text to German:\n\n{{ $json[\"sentence\"] }}",
"responseFormat": "json"
}
}
],
"connections": {
"Manual Trigger": { "main": [[{ "node": "Set Input", "type": "main", "index": 0 }]] },
"Set Input": { "main": [[{ "node": "Choose Language", "type": "main", "index": 0 }]] },
"Choose Language": {
"main": [
[{ "node": "Translate to Spanish", "type": "main", "index": 0 }],
[{ "node": "Translate to French", "type": "main", "index": 0 }],
[{ "node": "Translate to German", "type": "main", "index": 0 }]
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment