{
  "name": "Call Transcript Sentiment Analysis",
  "nodes": [
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "=gpt-4o-mini",
          "mode": "id"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        192,
        128
      ],
      "id": "23693edc-8b48-4da7-a65c-d4cafdc1b85c",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "id": "SsnwT4koLkkkT1th",
          "name": "OpenAI account"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        -256,
        32
      ],
      "id": "b1ba357d-6c55-4f27-995a-799c950d5fce",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 19
            }
          ]
        }
      },
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -704,
        32
      ],
      "id": "8a31f9a3-dcaa-4e12-8496-09b49770576b",
      "name": "Schedule Trigger"
    },
    {
      "parameters": {
        "documentId": {
          "__rl": true,
          "value": "1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU",
          "mode": "list",
          "cachedResultName": "Transcript_analysis_system"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        -480,
        32
      ],
      "id": "cb0182be-db98-47c7-b581-cc64a6143f98",
      "name": "Get All Transcript",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GojUvCMDXbhY8HrB",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "697b9e87-2767-43a8-9dfe-72c50903a5d5",
              "name": "Full Transcript",
              "value": "={{ $json[\"Full Transcript\"] }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -32,
        -96
      ],
      "id": "8ff46fcb-de6f-40ed-b637-417d016ffd35",
      "name": "Send only Transcript Field"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json[\"Full Transcript\"] }}",
        "hasOutputParser": true,
        "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 → After, e.g. \"Angry → Satisfied\")\n- Issue Resolved (Yes / No / Partially)"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        192,
        -96
      ],
      "id": "2b2c55c4-d8e5-478c-94ad-3654c8d51992",
      "name": "Analysis Transcript"
    },
    {
      "parameters": {
        "jsonSchemaExample": "{\n  \"Topic\": \"XYZ\",\n  \"Customer Name\": \"John D\",\n  \"Agent Name\": \"Emily R\",\n  \"Greeting Sentiment\": 5,\n  \"Closing Sentiment\": 5,\n  \"Problem Solving\": 5,\n  \"Agent Friendliness\": 5,\n  \"Customer Sentiment\": \"Frustrated → Satisfied\",\n  \"Issue Resolved\": \"Yes\"\n}"
      },
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        368,
        128
      ],
      "id": "b011f8d7-4f42-479a-b6f7-3e9c904532f7",
      "name": "Structured Output"
    },
    {
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "1aWU28D_73nvkDMPfTkPkaV53kHgX7cg0W4NwLzGFEGU",
          "mode": "list",
          "cachedResultName": "Transcript_analysis_system"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Sheet1"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Full Transcript": "={{ $('Loop Over Items').item.json['Full Transcript'] }}",
            "Status": "Done",
            "Customer Name": "={{ $json.output[\"Customer Name\"] }}",
            "Agent Name": "={{ $json.output[\"Agent Name\"] }}",
            "Greeting Sentiment": "={{ $json.output[\"Greeting Sentiment\"] }}",
            "Closing Sentiment": "={{ $json.output[\"Closing Sentiment\"] }}",
            "Problem Solving": "={{ $json.output[\"Problem Solving\"] }}",
            "Agent Friendliness": "={{ $json.output[\"Agent Friendliness\"] }}",
            "Customer Sentiment": "={{ $json.output[\"Customer Sentiment\"] }}",
            "Issue Resolved": "={{ $json.output[\"Issue Resolved\"] }}",
            "Total Rating": "={{( Number($json.output[\"Greeting Sentiment\"]) + Number($json.output[\"Closing Sentiment\"]) + Number($json.output[\"Problem Solving\"]) + Number($json.output[\"Agent Friendliness\"]))/4}}\n",
            "Conversations Topics": "={{ $json.output.Topic }}"
          },
          "matchingColumns": [
            "Full Transcript"
          ],
          "schema": [
            {
              "id": "Full Transcript",
              "displayName": "Full Transcript",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Conversations Topics",
              "displayName": "Conversations Topics",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Customer Name",
              "displayName": "Customer Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Name",
              "displayName": "Agent Name",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Greeting Sentiment",
              "displayName": "Greeting Sentiment",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Closing Sentiment",
              "displayName": "Closing Sentiment",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Problem Solving",
              "displayName": "Problem Solving",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Agent Friendliness",
              "displayName": "Agent Friendliness",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Customer Sentiment",
              "displayName": "Customer Sentiment",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Issue Resolved",
              "displayName": "Issue Resolved",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Rating",
              "displayName": "Total Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        608,
        32
      ],
      "id": "c8a43ef6-7f53-4fd1-8756-8ab8936852f3",
      "name": "Store Analysis Transcript",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "GojUvCMDXbhY8HrB",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "content": "### Data Setup\nCreate your own spreadsheet with these tabs/columns, then select it in the Google Sheets nodes:\n- **Transcript_analysis_system → Sheet1**: `Status`, `Full Transcript`, `Conversations Topics`, `Customer Name`, `Agent Name`, `Greeting Sentiment`, `Closing Sentiment`, `Problem Solving`, `Agent Friendliness`, `Customer Sentiment`, `Issue Resolved`, `Total Rating`",
        "height": 128,
        "width": 512
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -720,
        -176
      ],
      "typeVersion": 1,
      "id": "8f4b9d48-29b4-4557-90bf-f05b31bf3021",
      "name": "Sticky Note"
    }
  ],
  "pinData": {},
  "connections": {
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Analysis Transcript",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Send only Transcript Field",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get All Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get All Transcript": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send only Transcript Field": {
      "main": [
        [
          {
            "node": "Analysis Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analysis Transcript": {
      "main": [
        [
          {
            "node": "Store Analysis Transcript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output": {
      "ai_outputParser": [
        [
          {
            "node": "Analysis Transcript",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Store Analysis Transcript": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f0696f8f-9a69-4570-85b4-62fbae408e9d",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "f1c26778ec36097a9722a22c47c5e9c01f00b8862dadd0121ec118026a370fa6"
  },
  "id": "wZ8ggayHkCNvVdJI",
  "tags": []
}