Task: Streamlining CRM Management with GPT-4 Integration

n8n workflow JSON:
{"id":"61","meta":{"instanceId":"8d2955498ee87246afc459bb62a3d347cde10c94cb545928b54c958a4953963d"},"name":"Streamlining CRM with GPT-4 Integration","tags":[],"nodes":[{"id":"65702ada-4450-4960-8fb5-9e0c65a12bc2","name":"Trigger New Company","type":"n8n-nodes-base.hubspotTrigger","position":[160,280],"webhookId":"50318963-61a8-4e3d-904b-75707b602e2c","parameters":{"eventsUi":{"eventValues":[{"name":"company.creation"}]},"additionalFields":{}},"credentials":{"hubspotDeveloperApi":{"id":"57","name":"HubSpot Developer account 2"}},"typeVersion":1},{"id":"074759dc-aa4c-4a79-8f41-0731ddbaefa7","name":"GetHomepageHTML","type":"n8n-nodes-base.httpRequest","position":[900,280],"parameters":{"url":"=https://{{ $json.Domain }}","options":{"timeout":10000,"redirect":{"redirect":{}}}},"typeVersion":4},{"id":"c91bb1d5-b577-4e2a-8a9d-7122b5269eee","name":"ExtractTextOnly","type":"n8n-nodes-base.code","position":[1160,280],"parameters":{"jsCode":"let html = items[0].json[\"data\"];  // Replace \"html\" with your HTML field\n\n// Remove all HTML tags, JavaScript scripts, and CSS styles\nlet text = html.replace(/<script[^>]*>([\\s\\S]*?)<\\/script>/gi, '');\ntext = text.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi, '');\ntext = text.replace(/<\\/?[^>]+(>|$)/g, \"\");\n\n// Replace multiple whitespace characters with a single space\ntext = text.replace(/\\s\\s+/g, ' ');\n\nreturn [{json: {text: text}}];\n"},"typeVersion":1},{"id":"44e19012-0811-41e1-a0ba-23985f712787","name":"Map Industry","type":"n8n-nodes-base.openAi","position":[1400,280],"parameters":{"model":"gpt-4","prompt":{"messages":[{"role":"system","content":"You're an advanced business oriented with a keen understanding of industries.\nYou're tasked with identifying the industry of a company from a content."},{"content":"=Given the following content from a company's homepage, please identify the industry from the provided list that matches the given company's field. If there is no exact match, do not attempt to provide a best guess or create a new category. In the case that no match can be found, I would like you to return an empty value. \n\nWebsite content : {{ $json[\"text\"] }}\nHere's the list of industries : \nRetail / wholesale\nBusiness Services / Consulting\nEducation\nFinance / Insurance\n\nIf you cannot find a match within the provided list of industries, please refrain from making additional suggestions and simply return an empty value\n\n\n\n\n\nReturn the industry in this format : \nIndustry : \n\nAfter that analyse the content and give me a brieve description of the company focus and mission under 20 words, following this format \nMission : "}]},"options":{},"resource":"chat"},"credentials":{"openAiApi":{"id":"48","name":"OpenAi account"}},"typeVersion":1},{"id":"a1e1f503-a67a-4771-8642-73996550c4a2","name":"Industry/Mission","type":"n8n-nodes-base.code","position":[1640,280],"parameters":{"jsCode":"let messageContent = items[0].json.message.content;\n\nlet industryIndex = messageContent.indexOf(\"Industry :\");\nlet missionIndex = messageContent.indexOf(\"Mission :\");\n\nlet industryText = messageContent.slice(industryIndex + 11, missionIndex).trim();\nlet missionText = messageContent.slice(missionIndex + 9).trim();\n\nreturn [\n  {\n    json: {\n      industry: industryText,\n      mission: missionText\n    }\n  }\n];\n"},"typeVersion":1},{"id":"b685a00c-a343-4a16-ba7f-787a7a1c012b","name":"GetDomain","type":"n8n-nodes-base.set","position":[640,280],"parameters":{"values":{"string":[{"name":"Domain","value":"={{ $json.properties.domain.value }}"}]},"options":{},"keepOnlySet":true},"typeVersion":2},{"id":"a993e218-93ba-408f-bf44-7997bd2c0940","name":"UpdateCompany","type":"n8n-nodes-base.hubspot","position":[1840,280],"parameters":{"resource":"company","companyId":"={{ $node['Trigger New Company'].json.companyId }}","operation":"update","updateFields":{"customPropertiesUi":{"customPropertiesValues":[{"value":"={{ $json.industry }}","property":"industrie"}]}},"authentication":"oAuth2"},"credentials":{"hubspotOAuth2Api":{"id":"18","name":"Hubspot account Expensya"}},"typeVersion":1},{"id":"9173e5a2-5e3c-4d00-9c7a-05906228877a","name":"GetCompany","type":"n8n-nodes-base.hubspot","position":[400,280],"parameters":{"resource":"company","companyId":"={{ $json.companyId }}","operation":"get","authentication":"oAuth2","additionalFields":{}},"credentials":{"hubspotOAuth2Api":{"id":"18","name":"Hubspot account Expensya"}},"typeVersion":1},{"id":"b286d983-a0ac-4c7f-b122-b6a993ec6421","name":"Sticky Note","type":"n8n-nodes-base.stickyNote","position":[1300,60],"parameters":{"width":687.7850162866451,"height":513.4156255002331,"content":"## Integrating GPT for Enhanced Understanding of Company Sectors\n\n- Incorporate the specific industries from your CRM into the prompt.\n- If the field format is a dropdown menu, ensure the industries listed in the prompt are an exact match.\n- In this instance, the industry field is treated as a custom attribute. Remember to update it to correspond with your specific field in the CRM."},"typeVersion":1},{"id":"202fc9f3-7375-47b9-812e-62b18dd11b7f","name":"GetDate","type":"n8n-nodes-base.code","position":[2080,280],"parameters":{"jsCode":"return [\n  {\n    json: {\n      timestamp: Date.now(),\n    },\n  },\n];\n"},"typeVersion":1},{"id":"ccf62778-1d5b-4e89-8c7b-c6bf61c9fe3f","name":"Hubspot Note","type":"n8n-nodes-base.httpRequest","position":[2340,280],"parameters":{"url":"https://api.hubapi.com/engagements/v1/engagements?hapikey={{APIkey}}","method":"POST","options":{},"jsonBody":"={\n  \"engagement\": {\n    \"active\": true,\n    \"ownerId\": 1,\n    \"type\": \"NOTE\",\n    \"timestamp\": {{ $json[\"timestamp\"] }}\n  },\n  \"associations\": {\n    \"contactIds\": [],\n    \"companyIds\": [{{ $node[\"Trigger New Company\"].json[\"companyId\"] }}],\n    \"dealIds\": [],\n    \"ownerIds\": []\n\n  },\n  \"metadata\": {\n    \"body\": \"{{ $node[\"Industry/Mission\"].json[\"mission\"] }}\"\n  }\n}\n","sendBody":true,"sendHeaders":true,"specifyBody":"json","headerParameters":{"parameters":[{"name":"Content-Type","value":"application/json"}]}},"typeVersion":4},{"id":"6108564a-f174-4a1b-84ce-9a0202c8e4d0","name":"Sticky Note2","type":"n8n-nodes-base.stickyNote","position":[2000,57.34770777105632],"parameters":{"width":560.9446254071662,"height":516.267927408097,"content":"## Log company mission in a note\n\n- Update {{APIkey}}\n- Update owner id withy our Hubspot ID"},"typeVersion":1},{"id":"49e825f0-14bd-4f16-90ed-09e9a073c9f0","name":"Sticky Note1","type":"n8n-nodes-base.stickyNote","position":[120,60],"parameters":{"width":1159.94175151233,"height":514.211313168916,"content":"## Prepare the content\nRetrieve the text content from the homepage of each newly established company in the CRM by extracting it from the HTML page.\n\n\nyou can change the **trigger** if you're using different CRM"},"typeVersion":1}],"active":false,"pinData":{},"settings":{},"versionId":"7c39173f-37eb-4c98-8f6c-47b85d343bb1","connections":{"GetDate":{"main":[[{"node":"Hubspot Note","type":"main","index":0}]]},"GetDomain":{"main":[[{"node":"GetHomepageHTML","type":"main","index":0}]]},"GetCompany":{"main":[[{"node":"GetDomain","type":"main","index":0}]]},"Map Industry":{"main":[[{"node":"Industry/Mission","type":"main","index":0}]]},"UpdateCompany":{"main":[[{"node":"GetDate","type":"main","index":0}]]},"ExtractTextOnly":{"main":[[{"node":"Map Industry","type":"main","index":0}]]},"GetHomepageHTML":{"main":[[{"node":"ExtractTextOnly","type":"main","index":0}]]},"Industry/Mission":{"main":[[{"node":"UpdateCompany","type":"main","index":0}]]},"Trigger New Company":{"main":[[{"node":"GetCompany","type":"main","index":0}]]}}}