{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "45c60520-7937-4ccb-95e7-6805ee8e2f0a",
      "name": "Duplicate presentation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1872,
        2240
      ],
      "parameters": {
        "url": "=https://www.googleapis.com/drive/v3/files/{{ $('Set presentation id').item.json.presentationId }}/copy",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"name\": \"Claap x {{ $('Extract call info').item.json.client }} - Demo\"\n} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "googleDriveOAuth2Api"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "8b92b5d8-00c7-4394-b45f-ef925a943600",
      "name": "Publish presentation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2080,
        2240
      ],
      "parameters": {
        "url": "=https://www.googleapis.com/drive/v3/files/{{ $json.id }}/permissions?supportsAllDrives=true",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"role\": \"reader\",\n  \"type\": \"anyone\",\n  \"allowFileDiscovery\": true\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api"
      },
      "typeVersion": 4.2
    },
    {
      "id": "f594056f-b564-4ae8-b771-962640de5c8a",
      "name": "Set user as editor",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2304,
        2240
      ],
      "parameters": {
        "url": "=https://www.googleapis.com/drive/v3/files/{{ $('Duplicate presentation').item.json.id }}/permissions?supportsAllDrives=true",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"role\": \"writer\",\n  \"type\": \"user\",\n  \"emailAddress\": \"user@example.com\"\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0ce4dd64-60b6-42f4-a21e-836ad013a0b2",
      "name": "Select presentation template",
      "type": "n8n-nodes-base.switch",
      "position": [
        560,
        2528
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Discovery",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "6767bda7-f501-42d5-b70f-fbc427366c84",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('On new sales call recording').item.json.body.event.recording.labels.includes('Discovery') }}",
                    "rightValue": "Discovery"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Proposal",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d15a1cd6-f173-4f19-b126-56023ff972fc",
                    "operator": {
                      "type": "boolean",
                      "operation": "true",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('On new sales call recording').item.json.body.event.recording.labels.includes('Proposal') }}",
                    "rightValue": "={{ $('On new sales call recording').item.json.body.event.recording.labels.includes('Discovery') }}"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "28a66a03-b46b-4101-9228-cdb1f0c1a137",
      "name": "Extract call info",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        2528
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7d00c768-11f8-4e88-a72d-09f4680e6db5",
              "name": "client",
              "type": "string",
              "value": "={{ $json.body.event.recording.companies[0].name }}"
            },
            {
              "id": "899afd83-f493-4bf8-baa3-0af1357ba784",
              "name": "domain",
              "type": "string",
              "value": "={{ $json.body.event.recording.meeting.participants.find(p => p.email && p.email !== $json.body.event.recording.recorder.email)?.email.split(\"@\")[1] }}"
            },
            {
              "id": "53f353b3-8cbb-40d4-bd2f-13bf56554d7a",
              "name": "dealId",
              "type": "string",
              "value": "={{ $json.body.event.recording.crmInfo.crmDealId === undefined ? \"\" : $json.body.event.recording.crmInfo.crmDealId}}"
            },
            {
              "id": "61906ec6-d325-4e07-b05c-824a1d7e8c52",
              "name": "language",
              "type": "string",
              "value": "={{ $json.body.event.recording.transcripts[0].langIso2 === \"fr\" ? \"french\" : \"english\" }}"
            },
            {
              "id": "64575c62-a4bf-4748-854b-d31e1f9fc904",
              "name": "actionItems",
              "type": "string",
              "value": "={{ $json.body.event.recording.actionItems.join('\\n') }}"
            },
            {
              "id": "1e4964eb-11bc-40be-ae2d-acc3756f2f9c",
              "name": "keyTakeways",
              "type": "string",
              "value": "={{ $json.body.event.recording.keyTakeaways.join('\\n') }}"
            },
            {
              "id": "0594c03d-fbdb-4770-a3d7-f2793b90ac08",
              "name": "outlines",
              "type": "string",
              "value": "={{ $json.body.event.recording.outlines.join('\\n') }}"
            },
            {
              "id": "f632c9df-66ba-4b61-a3af-07a8ced06bb2",
              "name": "insights",
              "type": "string",
              "value": "={{ $json.body.event.recording.insightTemplates[0].insights[0].sections.map(section => `${section.title}:\\n${section.description}`).join('\\n\\n') }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "dd22c7f0-6515-4c0e-ad2e-a84e6d3690b2",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        2192
      ],
      "parameters": {
        "color": 2,
        "width": 600,
        "height": 240,
        "content": "# Template presentation\n- This template generates a sales follow-up presentation in Google Slides after a sales call recorded in Claap.\n- The workflow is simplified to showcase the main use case.\n- You can customize and enrich this workflow by connecting to the CRM, researching data online or adding more files in the presentation.\n- This workflow runs when the meeting is labeled with \"Discovery\" or \"Proposal\" in Claap.\n- The presentation template used in this workflow is available [here](https://docs.google.com/presentation/d/1UZ0vGvHWwl1M0u_ThxJr6qLr-flIkIvCiVrg3fHPCFk/edit?slide=id.g33acd02fb35_0_0)."
      },
      "typeVersion": 1
    },
    {
      "id": "5fc84ab3-2a83-4535-8d38-c271f87aa708",
      "name": "Set presentation id",
      "type": "n8n-nodes-base.set",
      "position": [
        1040,
        2240
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "70365c23-d99e-4975-8359-96f81968ebf1",
              "name": "presentationId",
              "type": "string",
              "value": "1UZ0vGvHWwl1M0u_ThxJr6qLr-flIkIvCiVrg3fHPCFk"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "6649d1d2-ce8b-4bb9-b473-ed0417249920",
      "name": "Update presentation",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2528,
        2240
      ],
      "parameters": {
        "url": "=https://slides.googleapis.com/v1/presentations/{{ $('Duplicate presentation').item.json.id }}:batchUpdate",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"requests\": [\n    {\n      \"replaceAllText\": {\n        \"containsText\": {\n          \"text\": \"$client\",\n          \"matchCase\": true\n        },\n        \"replaceText\": \"{{ $('Extract call info').item.json.client }}\"\n      }\n    },\n    {\n      \"replaceAllText\": {\n        \"containsText\": {\n          \"text\": \"$date\",\n          \"matchCase\": true\n        },\n        \"replaceText\": \"{{ new Date().toLocaleDateString('fr-FR') }}\"\n      }\n    },\n    {\n      \"replaceAllText\": {\n        \"containsText\": {\n          \"text\": \"$ambition\",\n          \"matchCase\": true\n        },\n        \"replaceText\": \"{{ $('Generate slide content').item.json.message.content.ambition }}\"\n      }\n    },\n    {\n      \"replaceAllText\": {\n        \"containsText\": {\n          \"text\": \"$challenges\",\n          \"matchCase\": true\n        },\n        \"replaceText\": \"{{ $('Format challenges').item.json.challengesFormatted }}\"\n      }\n    },\n    {\n      \"createImage\": {\n        \"url\": \"https://logo.clearbit.com/{{ $('Extract call info').item.json.domain }}\",\n        \"elementProperties\": {\n          \"pageObjectId\": \"g33acd02fb35_0_0\",\n          \"size\": {\n            \"height\": {\n              \"magnitude\": 50,\n              \"unit\": \"PT\"\n            },\n            \"width\": {\n              \"magnitude\": 100,\n              \"unit\": \"PT\"\n            }\n          },\n          \"transform\": {\n            \"scaleX\": 1,\n            \"scaleY\": 1,\n            \"translateX\": 0,\n            \"translateY\": 330,\n            \"unit\": \"PT\"\n          }\n        }\n      }\n    }\n  ]\n}\n",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleSlidesOAuth2Api"
      },
      "credentials": {
        "googleSlidesOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "972a826c-781f-4fd1-92d5-ec2f53f4825d",
      "name": "On new sales call recording",
      "type": "n8n-nodes-base.webhook",
      "position": [
        128,
        2528
      ],
      "parameters": {
        "path": "claap-recordings",
        "options": {},
        "httpMethod": "POST"
      },
      "typeVersion": 2
    },
    {
      "id": "6dfdb4b2-5c74-41a7-9edd-8f0eba4264b5",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        2528
      ],
      "parameters": {
        "width": 320,
        "height": 120,
        "content": "If several presentations can be selected based on the type of call, it's possible to create other branches here. You'll just need to provide the id of the presentation you want to duplicate."
      },
      "typeVersion": 1
    },
    {
      "id": "99b44269-6d1c-441d-b597-272597b1e1c8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2464,
        2432
      ],
      "parameters": {
        "height": 120,
        "content": "Another option is to use the n8n built-in node, but it offers less control (no full text search and replace and no possibility to add images)"
      },
      "typeVersion": 1
    },
    {
      "id": "8017b6bc-f516-4668-bf0a-cd708bb76ab8",
      "name": "Format challenges",
      "type": "n8n-nodes-base.code",
      "position": [
        1648,
        2240
      ],
      "parameters": {
        "jsCode": "return {\n  challengesFormatted: $input.first().json.message.content.challenges.join('\\\\n')\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "5aee27e9-17f0-4b0a-9b0e-e6bf0b82062b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1024,
        3024
      ],
      "parameters": {
        "width": 200,
        "height": 120,
        "content": "This branch showcases how to connect with the CRM and personalize the presentation based on CRM data"
      },
      "typeVersion": 1
    },
    {
      "id": "357ad95c-19ce-425a-b430-2e9cac0fe0a0",
      "name": "Delete wrong currency slide",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        784,
        3040
      ],
      "parameters": {
        "url": "=https://slides.googleapis.com/v1/presentations/{{ $('Duplicate presentation').item.json.id }}:batchUpdate",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"requests\": [\n    {\n      \"deleteObject\": {\n        \"objectId\": \"{{ $json.slide_to_delete }}\"\n      }\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleSlidesOAuth2Api"
      },
      "typeVersion": 4
    },
    {
      "id": "f129f806-564c-4820-a8fb-1516959ee780",
      "name": "Send to @user",
      "type": "n8n-nodes-base.slack",
      "position": [
        2784,
        2240
      ],
      "parameters": {
        "text": "=",
        "user": {
          "__rl": true,
          "mode": "username",
          "value": "@user"
        },
        "select": "user",
        "blocksUi": "={\n  \"blocks\": [\n    {\n      \"type\": \"section\",\n      \"text\": {\n        \"type\": \"mrkdwn\",\n        \"text\": \"*New presentation available for <https://docs.google.com/presentation/d/{{ $json.presentationId }}/edit#slide=id.g33acd02fb35_0_0|{{ $('Extract call info').item.json.client }}> \ud83d\udd25*\"\n      }\n    }\n  ]\n}",
        "messageType": "block",
        "otherOptions": {
          "includeLinkToWorkflow": false
        }
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "365237ff-823f-4b8c-928b-5b2bb8fc6bf7",
      "name": "If there is a deal",
      "type": "n8n-nodes-base.if",
      "position": [
        128,
        3040
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "49b2504c-0426-4dda-8249-8b147db94e6a",
              "operator": {
                "type": "string",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{ $('On new sales call recording').item.json.body.event.recording.deal.id }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "85c5809c-56f4-4648-b29e-ea4780634d75",
      "name": "Get deal info",
      "type": "n8n-nodes-base.hubspot",
      "position": [
        352,
        3040
      ],
      "parameters": {
        "dealId": "={{ $('On new sales call recording').item.json.body.event.recording.crmInfo.deal.id }}",
        "filters": {},
        "resource": "deal",
        "operation": "get",
        "authentication": "appToken"
      },
      "credentials": {
        "hubspotAppToken": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "253e418e-1282-4da1-8bd9-f9b2e013005e",
      "name": "Select slide to delete",
      "type": "n8n-nodes-base.set",
      "position": [
        560,
        3040
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "d462ed0b-f883-4adf-adc9-baa7d67d632b",
              "name": "slide_to_delete",
              "type": "string",
              "value": "={{ (!$json.properties.deal_currency_code.value || $json.properties.deal_currency_code.value === 'EUR') ? 'g3417703b8a7_0_3' : 'g3026f7d6b00_0_71' }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "65b78722-db75-4edc-ac9c-231cdb8e9336",
      "name": "Generate slide content",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        1264,
        2240
      ],
      "parameters": {
        "modelId": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "GPT-4O-MINI"
        },
        "options": {},
        "messages": {
          "values": [
            {
              "content": "=Your are a sales expert here to assist sales professionals in crafting follow-ups based on transcripts of discovery calls. Analyze the call summary to identify the following 2 elements:\n\n# Ambition: a summary of the prospect's goals or desired outcomes.\n# Challenges: list 3 key difficulties or obstacles discussed during the call.\n\nInstructions:\n- Use simple language and remain concise.\n- Output your answer in {{ $('Extract call info').item.json.language }}.\n- Structure your answer as a JSON:\n\n{ \n  \"ambition\": \"\",\n  \"challenges\": [\"\", \"\", \"\"]\n}\n\nCall summary below (within triple quotes):\n'''\n{{ $('Extract call info').item.json.insights }}\n'''"
            }
          ]
        },
        "jsonOutput": true
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.8
    },
    {
      "id": "dedfb07c-b450-4101-b7eb-7ff6a40aa5f5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        2496
      ],
      "parameters": {
        "color": 3,
        "width": 600,
        "height": 240,
        "content": "# Workflow configuration\n- Create a webhook in Claap, by following [this article](https://help.claap.io/en/articles/10395357-using-claap-s-webhooks).\n- Edit the labels that trigger the workflow and route on the relevant presentation.\n- Fill your Open AI credentials by creating an API Key in OpenAI Platform\n- Edit the presentation personalization details (user set as editor, content, title)\n- Fill your Slack credentials by following steps in [this video](https://www.youtube.com/watch?v=qk5JH6ImK0I&ab_channel=NateHerk%7CAIAutomation)."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Get deal info": {
      "main": [
        [
          {
            "node": "Select slide to delete",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract call info": {
      "main": [
        [
          {
            "node": "Select presentation template",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format challenges": {
      "main": [
        [
          {
            "node": "Duplicate presentation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If there is a deal": {
      "main": [
        [
          {
            "node": "Get deal info",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Set user as editor": {
      "main": [
        [
          {
            "node": "Update presentation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set presentation id": {
      "main": [
        [
          {
            "node": "Generate slide content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update presentation": {
      "main": [
        [
          {
            "node": "Send to @user",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Publish presentation": {
      "main": [
        [
          {
            "node": "Set user as editor",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Duplicate presentation": {
      "main": [
        [
          {
            "node": "Publish presentation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate slide content": {
      "main": [
        [
          {
            "node": "Format challenges",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select slide to delete": {
      "main": [
        [
          {
            "node": "Delete wrong currency slide",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On new sales call recording": {
      "main": [
        [
          {
            "node": "Extract call info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select presentation template": {
      "main": [
        [
          {
            "node": "Set presentation id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}