Get history from Slack

Hey!

I am trying to make a chatbot, that looks at previous history in a Slack channel when it creates an answer. So for example we work for a streaming service, and a question could be “can you provide history on previous issues with chromecast?”, and then it looks up and uses history from the Slack channel to answer.
I have made the workflow below, and made the settings for each node as attached as well. The result is that no matter what question I ask, I always get the text from the latest Slack message to the channel as output.

Anyone who can guide me on how to make this works? Thank you.



Information on your n8n setup

  • n8n version:
    1.59.4
  • Database (default: SQLite):
    None.
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
    Default.
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
    Cloud
  • Operating system:
    Sonoma 14.7

Hey @Clausladefoged,

Can you share the actual json for the workflow so we can give it a test?

Hi @Jon,

Sure, it is below, thanks.

{
“name”: “Consumer Channels”,
“nodes”: [
{
“parameters”: {},
“id”: “45b138ba-c9a5-42d0-84d7-fa46ff438cf6”,
“name”: “Window Buffer Memory”,
“type”: “@n8n/n8n-nodes-langchain.memoryBufferWindow”,
“typeVersion”: 1.2,
“position”: [
1060,
780
]
},
{
“parameters”: {
“options”: {}
},
“id”: “3f0d5085-16e5-4340-b2ff-531bf5535c36”,
“name”: “OpenAI Chat Model”,
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1,
“position”: [
920,
780
],
“credentials”: {
“openAiApi”: {
“id”: “N3klvFb5bO8X2WyG”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {},
“id”: “7c88a0ff-8fc4-4108-a9c2-ebc61bb7a0c7”,
“name”: “Calculator”,
“type”: “@n8n/n8n-nodes-langchain.toolCalculator”,
“typeVersion”: 1,
“position”: [
1200,
780
]
},
{
“parameters”: {
“fieldsToAggregate”: {
“fieldToAggregate”: [
{}
]
},
“options”: {}
},
“id”: “b63171bc-2825-4405-8cdf-47f36200a3f2”,
“name”: “Aggregate”,
“type”: “n8n-nodes-base.aggregate”,
“typeVersion”: 1,
“position”: [
1680,
880
]
},
{
“parameters”: {
“options”: {}
},
“id”: “3122fbed-e4ad-4ac1-a322-d6be6b1b3ab2”,
“name”: “OpenAI Chat Model1”,
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1,
“position”: [
1440,
1040
],
“credentials”: {
“openAiApi”: {
“id”: “N3klvFb5bO8X2WyG”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“fieldsToAggregate”: {
“fieldToAggregate”: [
{}
]
},
“options”: {}
},
“id”: “bdc080d1-7b82-4228-a37f-56319c9e0c41”,
“name”: “Aggregate1”,
“type”: “n8n-nodes-base.aggregate”,
“typeVersion”: 1,
“position”: [
1680,
540
]
},
{
“parameters”: {
“options”: {}
},
“id”: “00176e41-4b40-4d04-8a4a-0d9ed8e2d488”,
“name”: “OpenAI Chat Model2”,
“type”: “@n8n/n8n-nodes-langchain.lmChatOpenAi”,
“typeVersion”: 1,
“position”: [
1440,
700
],
“credentials”: {
“openAiApi”: {
“id”: “N3klvFb5bO8X2WyG”,
“name”: “OpenAi account”
}
}
},
{
“parameters”: {
“resource”: “organization”,
“owner”: {
“__rl”: true,
“value”: “NordiskFilmDistribution”,
“mode”: “list”,
“cachedResultName”: “NordiskFilmDistribution”,
“cachedResultUrl”: “Nordisk Film Distribution A/S · GitHub
},
“returnAll”: true
},
“id”: “ddf4c53a-ce1b-43ef-bc1e-5c3743a9f509”,
“name”: “GitHub”,
“type”: “n8n-nodes-base.github”,
“typeVersion”: 1,
“position”: [
1900,
540
],
“credentials”: {
“githubApi”: {
“id”: “xLtUH0plVIT6hUiM”,
“name”: “GitHub account 2”
}
}
},
{
“parameters”: {
“options”: {
“systemMessage”: “You find historical knowledge on the issue you are being asked, and use your sources to list previous examples of the issue.”
}
},
“id”: “7b93db10-6240-47d9-8224-d07caec9d8c6”,
“name”: “AI Consumer Channels”,
“type”: “@n8n/n8n-nodes-langchain.agent”,
“typeVersion”: 1.6,
“position”: [
1020,
540
]
},
{
“parameters”: {
“public”: true,
“options”: {}
},
“id”: “1f5eecfd-e30a-4ed4-b93e-96dcfc28a043”,
“name”: “When chat message received1”,
“type”: “@n8n/n8n-nodes-langchain.chatTrigger”,
“typeVersion”: 1.1,
“position”: [
760,
540
],
“webhookId”: “705a71a7-1cd3-4ac4-9a2e-2064fe40f73e”
},
{
“parameters”: {
“path”: “99dd9ffb-0840-4068-aafc-734c44103950”,
“responseMode”: “lastNode”,
“responseData”: “allEntries”,
“options”: {}
},
“id”: “71ee676b-e124-4dd5-a4df-799ef59bd83f”,
“name”: “Webhook”,
“type”: “n8n-nodes-base.webhook”,
“typeVersion”: 2,
“position”: [
760,
380
],
“webhookId”: “99dd9ffb-0840-4068-aafc-734c44103950”
},
{
“parameters”: {
“resource”: “channel”,
“operation”: “history”,
“channelId”: {
“__rl”: true,
“value”: “C79C2EL6B”,
“mode”: “list”,
“cachedResultName”: “help-tech”
},
“returnAll”: true,
“filters”: {
“inclusive”: true
}
},
“id”: “4008f5d4-7dcb-49d5-bd93-50df4f93653a”,
“name”: “Slack”,
“type”: “n8n-nodes-base.slack”,
“typeVersion”: 2.2,
“position”: [
1900,
880
],
“credentials”: {
“slackApi”: {
“id”: “v54St0iqXOlWZyXd”,
“name”: “Slack account 13”
}
}
},
{
“parameters”: {},
“id”: “bdb2d34e-e286-4c62-9f7a-1835fbaeb9d1”,
“name”: “Basic LLM Chain”,
“type”: “@n8n/n8n-nodes-langchain.chainLlm”,
“typeVersion”: 1.4,
“position”: [
1360,
540
],
“alwaysOutputData”: false,
“onError”: “continueRegularOutput”
},
{
“parameters”: {},
“id”: “448e6f79-5c1c-45fd-8449-bbca84badda3”,
“name”: “Basic LLM Chain1”,
“type”: “@n8n/n8n-nodes-langchain.chainLlm”,
“typeVersion”: 1.4,
“position”: [
1360,
880
],
“alwaysOutputData”: false,
“onError”: “continueRegularOutput”
}
],
“pinData”: {},
“connections”: {
“Window Buffer Memory”: {
“ai_memory”: [
[
{
“node”: “AI Consumer Channels”,
“type”: “ai_memory”,
“index”: 0
}
]
]
},
“OpenAI Chat Model”: {
“ai_languageModel”: [
[
{
“node”: “AI Consumer Channels”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Calculator”: {
“ai_tool”: [
[
{
“node”: “AI Consumer Channels”,
“type”: “ai_tool”,
“index”: 0
}
]
]
},
“OpenAI Chat Model1”: {
“ai_languageModel”: [
[
{
“node”: “Basic LLM Chain1”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“Aggregate”: {
“main”: [
[
{
“node”: “Slack”,
“type”: “main”,
“index”: 0
}
]
]
},
“Aggregate1”: {
“main”: [
[
{
“node”: “GitHub”,
“type”: “main”,
“index”: 0
}
]
]
},
“OpenAI Chat Model2”: {
“ai_languageModel”: [
[
{
“node”: “Basic LLM Chain”,
“type”: “ai_languageModel”,
“index”: 0
}
]
]
},
“AI Consumer Channels”: {
“main”: [
[
{
“node”: “Basic LLM Chain1”,
“type”: “main”,
“index”: 0
},
{
“node”: “Basic LLM Chain”,
“type”: “main”,
“index”: 0
}
]
]
},
“When chat message received1”: {
“main”: [
[
{
“node”: “AI Consumer Channels”,
“type”: “main”,
“index”: 0
}
]
]
},
“Webhook”: {
“main”: [
[
{
“node”: “AI Consumer Channels”,
“type”: “main”,
“index”: 0
}
]
]
},
“Basic LLM Chain”: {
“main”: [
[
{
“node”: “Aggregate1”,
“type”: “main”,
“index”: 0
}
]
]
},
“Basic LLM Chain1”: {
“main”: [
[
{
“node”: “Aggregate”,
“type”: “main”,
“index”: 0
}
]
]
}
},
“active”: true,
“settings”: {
“executionOrder”: “v1”
},
“versionId”: “966c7cd9-7977-413d-9de9-198a21b5fd9c”,
“meta”: {
“templateCredsSetupCompleted”: true,
“instanceId”: “0c54e523e1ced82b0ee704684432ac28ca23bd05caf3f3c7cdb403337cb81fbc”
},
“id”: “o01wGgJObfafrR1p”,
“tags”:
}

Would appreciate if someone can help with this :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.