webhook → if topic_id is empty
→ True - Mysql node SELECT * FROM sqms_topic;
→ False - Mysql node SELECT * FROM sqms_topic where sqms_topic_id = {{$json[“query”][“topic_id”]}};
Then I make two identical calls (for each path) to a translation API
Do I really need 2 mysql and 2 http query nodes or can I send the query dynamically depending on topic_id is sent or not?
I would use two different nodes like the way you did. This allows me to understand the data flow in the workflow better. This approach will also make debugging easy.
I tried to add a merge node after the 2 sql calls but I could only add 1 http request but I failed
You can connect only one node to the output of the Merge node. Do you really need two different HTTP Request nodes? Looking at your workflow, both the nodes are identical. Did you try with a single node? Can you share what error you get, if any?
the http request node returns only the last result - how can I merge the sql query result and the translation result?
Can you share some more information here? If the MySQL node returns 10 items, the HTTP Request node will process these 10 items and return you 10 translations.
You can use the Set node or the Function node to merge the outputs from the SQL Query node and the translation node.
[
{
"sqms_topic_id": 1,
"name": "Topic with ID [1]",
"sqms_role_id": 2
},{...},
{
"sqms_topic_id": 19,
"name": "Topic with ID [19]",
"sqms_role_id": 6
}
]
from the translate node I get back
[
{
"source_text": "Topic with ID [1]",
"source_lang": "EN",
"target_text": "Tema con ID [1]",
"target_lang": "ES"
},
{...},
{
"source_text": "Topic with ID [19]",
"source_lang": "EN",
"target_text": "Tema con ID [19]",
"target_lang": "ES"
}
]
I would like to have
[
{
"sqms_topic_id": 1,
"source_text": "Topic with ID [1]",
"source_lang": "EN",
"target_text": "Tema con ID [1]",
"target_lang": "ES"
"sqms_role_id": 2
}, {...},
{
"sqms_topic_id": 19,
"source_text": "Topic with ID [19]",
"source_lang": "EN",
"target_text": "Tema con ID [19]",
"target_lang": "ES"
"sqms_role_id": 3
}
]
Did you try the Set node? You can specify the fields you want and only return these fields.
Since you have two SQL nodes connected to the HTTP Request node, and we need to take care of the condition when either of the nodes runs, you can add a NoOp node before the HTTP Request node. In the Set node, you can refer these values from the NoOp node.