{
  "id": "6kTlui6CDAIL3vNV",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "call-center-transcription-sentiment-analysis-n8n",
  "tags": [],
  "nodes": [
    {
      "id": "eee89774-3c9b-4e26-8bf2-9f14ee1ced97",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        192,
        128
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "id",
          "value": "=gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "77912e60-0f2a-4434-b8c7-00bc53c474a9",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -256,
        32
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "d44b524d-3b67-4c48-8d52-34bba6ad16b9",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -704,
        32
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 19
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3173c049-13c7-483c-a6ea-65340bf585f9",
      "name": "Get All Transcript",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -480,
        32
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU/edit?usp=drivesdk",
          "cachedResultName": "Transcript_analysis_system"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "856d4c88-f8a6-41ab-b52c-639e58df2b0c",
      "name": "Send only Transcript Field",
      "type": "n8n-nodes-base.set",
      "position": [
        -32,
        -96
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "697b9e87-2767-43a8-9dfe-72c50903a5d5",
              "name": "Full Transcript",
              "type": "string",
              "value": "={{ $json[\"Full Transcript\"] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "0aa10ec0-c836-44df-ad85-9a503e1d10e3",
      "name": "Analysis Transcript",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        192,
        -96
      ],
      "parameters": {
        "text": "={{ $json[\"Full Transcript\"] }}",
        "options": {
          "systemMessage": "=You are an advanced AI assistant specialized in sentiment analysis for customer service conversations.\n\nYour task is to extract structured data from a customer service chat transcript. Return values for each field listed below.\n\nRespond in JSON format using structured output tool with the following fields:\n\n\n- Topic (Topic name for discussion like 'Medical Report','shipping delay')\n- Customer Name\n- Agent Name\n- Greeting Sentiment (1 to 5, where 5 is very polite/friendly/Greeting and 1 is rude)\n- Closing Sentiment (1 to 5, where 5 is very Closing polite/friendly and 1 is rude)\n- Problem Solving (1 to 5, where 5 is excellent and 1 is poor)\n- Agent Friendliness (1 to 5, where 5 is very polite/friendly and 1 is rude)\n- Customer Sentiment (Before \u2192 After, e.g. \"Angry \u2192 Satisfied\")\n- Issue Resolved (Yes / No / Partially)"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2
    },
    {
      "id": "1c427949-04d9-4ed8-9d17-d62bf34c18e8",
      "name": "Structured Output",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        368,
        128
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"Topic\": \"XYZ\",\n  \"Customer Name\": \"John D\",\n  \"Agent Name\": \"Priya M\",\n  \"Greeting Sentiment\": 5,\n  \"Closing Sentiment\": 5,\n  \"Problem Solving\": 5,\n  \"Agent Friendliness\": 5,\n  \"Customer Sentiment\": \"Frustrated \u2192 Satisfied\",\n  \"Issue Resolved\": \"Yes\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "79c31b02-f5bc-4185-b83a-6ca7caa25f6c",
      "name": "Store Analysis Transcript",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        608,
        32
      ],
      "parameters": {
        "columns": {
          "value": {
            "Status": "Done",
            "Agent Name": "={{ $json.output[\"Agent Name\"] }}",
            "Total Rating": "={{( Number($json.output[\"Greeting Sentiment\"]) + Number($json.output[\"Closing Sentiment\"]) + Number($json.output[\"Problem Solving\"]) + Number($json.output[\"Agent Friendliness\"]))/4}}\n",
            "Customer Name": "={{ $json.output[\"Customer Name\"] }}",
            "Issue Resolved": "={{ $json.output[\"Issue Resolved\"] }}",
            "Full Transcript": "={{ $('Loop Over Items').item.json['Full Transcript'] }}",
            "Problem Solving": "={{ $json.output[\"Problem Solving\"] }}",
            "Closing Sentiment": "={{ $json.output[\"Closing Sentiment\"] }}",
            "Agent Friendliness": "={{ $json.output[\"Agent Friendliness\"] }}",
            "Customer Sentiment": "={{ $json.output[\"Customer Sentiment\"] }}",
            "Greeting Sentiment": "={{ $json.output[\"Greeting Sentiment\"] }}",
            "Conversations Topics": "={{ $json.output.Topic }}"
          },
          "schema": [
            {
              "id": "Full Transcript",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Full Transcript",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Conversations Topics",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Conversations Topics",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Customer Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Greeting Sentiment",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Greeting Sentiment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Closing Sentiment",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Closing Sentiment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Problem Solving",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Problem Solving",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Friendliness",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Agent Friendliness",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Sentiment",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Customer Sentiment",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Issue Resolved",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Issue Resolved",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Rating",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Total Rating",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": true,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Full Transcript"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU/edit?usp=drivesdk",
          "cachedResultName": "Transcript_analysis_system"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "735bad42-0258-4076-a4d2-939a4a2677f6",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -176
      ],
      "parameters": {
        "width": 512,
        "height": 128,
        "content": "### Sample Google Sheet\n\nhttps://docs.google.com/spreadsheets/d/1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU/edit?gid=0#gid=0"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a54e879a-6738-4edb-b195-8b47945d70a7",
  "connections": {
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Send only Transcript Field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get All Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analysis Transcript",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "Analysis Transcript",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Get All Transcript": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analysis Transcript": {
      "main": [
        [
          {
            "node": "Store Analysis Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Analysis Transcript": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send only Transcript Field": {
      "main": [
        [
          {
            "node": "Analysis Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}