{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "97666a2e-e006-4dd4-bb52-844f67cf0f67",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        272,
        624
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "57d266ad-fa73-4e7a-8630-200e6bdc0da0",
              "name": "payload.email",
              "type": "string",
              "value": "={{ $json.payload.email }}"
            },
            {
              "id": "01b92620-7ee3-4805-bee8-ac8a3e9971fd",
              "name": "payload.questions_and_answers[0].answer",
              "type": "string",
              "value": "={{ $json.payload.questions_and_answers[0].answer }}"
            },
            {
              "id": "3742a6c0-d214-4020-bab3-cdae2c7a297c",
              "name": "payload.name",
              "type": "string",
              "value": "={{ $json.payload.name }}"
            },
            {
              "id": "a195c86d-8f23-4787-8a44-15d9e15d2396",
              "name": "payload.scheduled_event.start_time",
              "type": "string",
              "value": "={{ $json.payload.scheduled_event.start_time }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "d0e2aff7-febd-4ccc-8a01-0ecbf86fc142",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        432,
        864
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ec9e6d3d-e4ea-4500-82c0-a8d48a069f41",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        656,
        832
      ],
      "parameters": {
        "jsonSchemaExample": "{\n\t\"email\": \"html email\",\n\t\"slack\": \"Slack Message\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "7ce1112f-7649-47f4-a9a2-5c829da7fd6c",
      "name": "Send a message",
      "type": "n8n-nodes-base.microsoftOutlook",
      "position": [
        848,
        560
      ],
      "parameters": {
        "subject": "Calendly Details",
        "bodyContent": "={{ $json.output.email }}",
        "toRecipients": "={{ $('Edit Fields').item.json.payload.email }}",
        "additionalFields": {
          "bodyContentType": "html"
        }
      },
      "credentials": {
        "microsoftOutlookOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "1f87bd9f-9127-4436-b6fe-1104dd47844c",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        -320
      ],
      "parameters": {
        "width": 1680,
        "content": "## \ud83d\udcec Need Help or Want to Customize This?\n\ud83d\udce7 [robert@ynteractive.com](mailto:robert@ynteractive.com)  \n\ud83d\udd17 [LinkedIn](https://www.linkedin.com/in/robert-breen-29429625/)"
      },
      "typeVersion": 1
    },
    {
      "id": "75ddecca-3f1a-4e68-b1b4-c6d0b1a9288c",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        -128
      ],
      "parameters": {
        "color": 4,
        "width": 1680,
        "height": 1168,
        "content": "### \u2699\ufe0f Step-by-Step Setup Instructions\n\n#### 1. \ud83d\udd17 Calendly API Setup\n- In n8n: Go to **Credentials \u2192 Add Credential \u2192 Calendly API**.\n- Connect your account with the personal access token.\n- In the **Calendly Trigger** node, set event to `invitee.created`.\n\n#### 2. \ud83d\udce7 Microsoft Outlook Credential\n- Add Microsoft Outlook credentials via OAuth2 in **n8n \u2192 Credentials**.\n- Select it in the \"Send a message\" node.\n\n#### 3. \ud83d\udcac Slack Setup\n- Add Slack OAuth2 credentials.\n- Select your Slack workspace and choose the channel (e.g., `#leads`).\n\n#### 4. \ud83e\udde0 Configure the AI Agent (OpenAI)\n- Provide your OpenAI API key under **Credentials \u2192 OpenAI API**.\n- The AI Agent node is pre-configured to:\n  - Format a custom Slack message\n  - Format a custom Outlook HTML email\n\n#### 5. \ud83d\udee0 Node Details\n- **Calendly Event** (Trigger): Listens for new bookings\n- **Edit Fields**: Extracts values like name, email, start time, and form answers\n- **Email Generator** (AI Agent): Creates formatted email + Slack message\n- **Send a message** (Outlook): Sends the formatted email to your inbox\n- **Slack Message**: Sends the AI-generated Slack alert\n"
      },
      "typeVersion": 1
    },
    {
      "id": "af63afc3-8917-4399-a349-696a0477796d",
      "name": "Calendly Event",
      "type": "n8n-nodes-base.calendlyTrigger",
      "position": [
        32,
        624
      ],
      "parameters": {
        "events": [
          "invitee.created"
        ]
      },
      "credentials": {
        "calendlyApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b1830f4e-27ae-465f-9e2b-2efaf38eba2f",
      "name": "Slack Message",
      "type": "n8n-nodes-base.slack",
      "position": [
        880,
        768
      ],
      "parameters": {
        "text": "={{ $('Email Generator').item.json.output.slack }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#leads"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "74d9805a-97b7-4e86-ae50-b6a2af5b85be",
      "name": "Email Generator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        480,
        624
      ],
      "parameters": {
        "text": "=Name:  {{ $json.payload.name }} About:  {{ $json.payload.questions_and_answers[0].answer }} Start Time: {{ $json.payload.scheduled_event.start_time }}",
        "options": {
          "systemMessage": "You are a helpful assistant. Write an email and a slack message notifying me that someone booked a calendly appt with me. Output the slack message in text. and the outlook message in html. \n\noutput like this. \n\n{\n\t\"email\": \"html email\",\n\t\"slack\": \"Slack Message\"\n}"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 2.2
    }
  ],
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Email Generator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Calendly Event": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send a message": {
      "main": [
        []
      ]
    },
    "Email Generator": {
      "main": [
        [
          {
            "node": "Send a message",
            "type": "main",
            "index": 0
          },
          {
            "node": "Slack Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Email Generator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Email Generator",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    }
  }
}