Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat: cal.com webhook → Meta Lead events (#2764)

Evan Hutnikd2ee6bfb5daf
diff --git a/.env-local.enc b/.env-local.enc
index 320bcf564e..4f1d4a2425 100644
--- a/.env-local.enc
+++ b/.env-local.enc
@@ -10,6 +10,8 @@ BACKFILL_QUEUE_MAX_MESSAGES=ENC[AES256_GCM,data:AUZs,iv:ST7hFsgaTX7UywBwkXSXy9lG
BACKFILL_QUEUE_WORKERS=ENC[AES256_GCM,data:YhcxQg==,iv:Er4O0ADEgBRh3VO7piwpgfHEYxE3EDElhZumgXbmpeM=,tag:GMU00vKvkv3BxzDM6Kx21A==,type:str]
BASE_URL=ENC[AES256_GCM,data:xDjxmXaorCF6bJrhDXR9iOa3o0EmeLo=,iv:Lykqt28CCm4R8904NuYVsjF85LimXDstKWBHDpkRlho=,tag:yVwo912yzgOtP6HOBR6V2A==,type:str]
BULK_UPLOAD_REQUESTS_TABLE=ENC[AES256_GCM,data:cXp1qV7PPvB56zxE5w==,iv:xwGz3jX0XW10LMeHoyuASDjlKl+3cz+eh9URhjVF6aM=,tag:gaZJkg5hi3Syvj22YhHRlQ==,type:str]
+CAL_EVENT_TYPE_CONTENT_NAMES_KEY=ENC[AES256_GCM,data:/fmIDA==,iv:rhQAneFAPQDg1/Wme1TOGh76WFNStTxCDNz12O9s/9I=,tag:uh0UUm20wHRRPe0WFsSFBw==,type:str]
+CAL_WEBHOOK_SECRET_KEY=ENC[AES256_GCM,data:t2Hn2JoB,iv:ohQBFZv8wLSAq3rD+a2FiYiIIyVjl/41BI1FAHOvTKs=,tag:w7VwyNGh+elSnoYl3bdGnw==,type:str]
CHAT_DELETE_QUEUE=ENC[AES256_GCM,data:Xm6XSh6Ge6NZxjcGPQVxEN7n1zOXWHh20Ox6Awq9NZN9B2Tt73eWqnHigAYPH9+j+m7k7IwTiRR3hOKy6zMA,iv:mWH/r2WYI1DOiE1BlpiuIJIv7q5behiMhvfiGDDEDgQ=,tag:tofQrMiWYeF2oPdvLydFZg==,type:str]
CONNECTION_GATEWAY_TABLE=ENC[AES256_GCM,data:KqDjSn/o+AlZVOoz4eT9LjEyB0/SoNHS+S0=,iv:HixjrQocTF2TEhDv0amx2zvIJEHaEwLbHDNAqW2tm4U=,tag:jzFPSEvF5jF7Hy5XPGgXDA==,type:str]
CONNECTION_GATEWAY_URL=ENC[AES256_GCM,data:IeVOPf+CgNUcjfjvhUXkiKitTUIs1A9tFU9VwS6ChUU=,iv:wDlz3TYK9poXAeLaz9v9MQ03SDT6PIBO+/P0dWqK6ZQ=,tag:kRQtJUXaauNE/zsIrGOvQw==,type:str]
@@ -70,6 +72,8 @@ MACRO_API_TOKEN_ISSUER=ENC[AES256_GCM,data:x3ZbbfnAgw==,iv:G77sXNKqa8sYQ+/Ml6z9N
MACRO_API_TOKEN_PRIVATE_SECRET_KEY=ENC[AES256_GCM,data:v2EhHmJU1dLlem/Q+tKGYTRc4vDgqfNN8m4VIk0IORF7MndM4QRdLY+tnaHuUez0p4kOE88chbz0Jf+AxEiuC92raj4CIDcTqhf/rdkR/2KTKGnFez5fTdycaI+z8kh176fh3MJMW6mXP9GkD0SPhwwbgh0bkaQUx6YQchdrIy/ciX+KYshc+fIb7YF6tni3bgziBsBCQzzF/uyvXXvPDCgcx8RdZ3PF0SqXAFdEDpHZNfhydAuPPIr1begat9QMbTKRVud+uvbZUDKWp0wPcOI+8Sl0SQWOW8GZyGe0ZqiogOmoVlX+mc5d31+IirlTSTdYxLQ60EUkS0q+4ZVSuNJp0jyPN7OvySacFgYt6XQzlBZmz09STCO/vBs642Z9rymlpIpQ2hZjotoWQq4M/sKr12Sp/nT7Y5ywUYpxYKk3GZ/8TTRMU+2cXmN8f85Z/bNadkTMJWRgMWs7GwI5sHbtbk+fBNHRHoREJ35+V7vuubNhbZCvwVmT6KI+7A3+7IKE33fYytofowJAyP7toyw548I506zizFiajkICuJ+N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bMTLomxgA7h55nwiSS1Qa4YGFEkjpohXzsoLo4hsJN95TQTHrW/lXs2XRp7KS+kseI/iP91j7W3XA4GqO+G14E3pFbWEiKn0IcmkwkmmwCsjD5dr3ofoDVS6G4FpMb+NW/Suy3rns0KK22vma2yW37fcpV6+jvO/j9r4ATO84vkRD9kundORGuVYfuaLZ4cPGJxO9VpACXVmptTANAyqv/2lnETRQSSGE93S+B4/VpST6AFkSGYc=,iv:nN2Yfe870sTNs8PIByeo811ttTam2SWLY2/5fPOUS3w=,tag:1m76zFV3xf+04hs/Qcv4OQ==,type:str]
MACRO_DB_URL=ENC[AES256_GCM,data:pHIgQStne3Q8Oh9XpL19IHxqFIA7v5V/5p5tTUdzkZapePf15pBB4Ds+2HkhXL6E,iv:7TXBl2sBbl3q/uIBKbLVOWhCnM5nK+64BYQ/EQmPiTo=,tag:RfYznyUnFCdIKE8UeH9waA==,type:str]
+META_ACCESS_TOKEN=ENC[AES256_GCM,data:0McjOrhO,iv:R3PH9qItFPXw5uHyofSgGNT7cp0lP5ODnERpmRBrd/w=,tag:wgimXHRc3cInKjZ/zX8cwg==,type:str]
+META_PIXEL_ID=ENC[AES256_GCM,data:ZCowkiPO,iv:ud6fa/QRnC3MmRCuUMPs88QI9P4bK+38LA1PRmaN1Gw=,tag:3d1QVQlpl+KuTwAbGp+K1A==,type:str]
NOTIFICATIONS_ENABLED=ENC[AES256_GCM,data:4g0fE6Ne,iv:bkGy1Xou2yJNch8ybq7XFPtmngfY1Ib3+uZjWy81WoE=,tag:tY4BGO/LLqfWk+OzsUvqAQ==,type:str]
NOTIFICATION_QUEUE=ENC[AES256_GCM,data:ObcXTgAyISCZqJK/nrJLAKe2/T2W64PNS+MdVWKap0saoNX2hiIFTQ0P9PLIVgltkiC+xIi9j7Y=,iv:0a4rl9zaS2ByAP8et4qjo0xZYBHQMEuF7jy5D1bhavk=,tag:rxR86sd50sPzlcJ9z2wffg==,type:str]
OPENAI_API_KEY=ENC[AES256_GCM,data:hxQQhVXzn8uaZspmnXCRS3fGU3xDYKAJzi7JNYbcWAFpMX1BBTN27iMIHBKAM30JoKIiJJKn9VGYoShMskv3vW1PYK2acOjfApDHGQPhzlzMnt6kasUQXV+77ezdvPMdPG+6/a/AZd9W4zduElScEe+zey6JVIsEOXfI8nKSkj8SuW215HRcwbPUE/DPuiwdvxLdAqKzwwr7CQki5pu1dOabvrLEnA==,iv:tJSDvjGwsjlFzgff2LZMt7XAnNCHwYm3LjV3LsotRus=,tag:MKhqNn0lYvcDNZwUvxyl2A==,type:str]
@@ -139,7 +143,7 @@ sops_kms__list_1__map_arn=arn:aws:kms:us-west-1:569036502058:key/mrk-cab29bf9480
sops_kms__list_1__map_aws_profile=
sops_kms__list_1__map_created_at=2026-03-03T19:32:07Z
sops_kms__list_1__map_enc=AQICAHjuYcSMsjB0lKJtZ3DIAvxF8N3RNRn5KZaAN74Et6122wFUqf7u/HEfCUGv7j69Mb6YAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMpcJQR1XeIAFFE7ebAgEQgDvYRYIWelwN8TuwA+6fZVaB34yKo9EQ5xPLr/3BU+ro1Mn2eBPCg3q8ie2LuE/3voim1X35P/cdtDqTZg==
-sops_lastmodified=2026-04-07T15:42:26Z
-sops_mac=ENC[AES256_GCM,data:xtZ2KnO66PdYX0CH6ZaQ7rGrgTQHL3wrzClBUtAfgbjQlGVn28XvH6eBuNreIgvaDL02NRYb1fPE7tvBNLdea4pLbL7hyR1188ErxouuifKY+oWArXxZU03IQ/zyXTaRKupTKjT/JvR2lrkz6ksy6KxDqoOKq+UEmDsifG/3Cvw=,iv:FBHOX35jhuUtEDH2WCOQZHRJSvWtt6gUfUA4BaEK9Mg=,tag:ssDHMj08cQI1zvYgJ9S+9A==,type:str]
+sops_lastmodified=2026-04-22T15:12:33Z
+sops_mac=ENC[AES256_GCM,data:JpVvlGmEDfjrHsyENl8eWyXs1gCJjW7p/enu+AdAIK6Si2x5/UpVcm9EJQl2t4pqLh+ml3ZndycoJakzQqrPh8lyST/BvXxYdu1ry8RMCkvixRxmhedUvc5ffhKWCx6h1KZG0Bnb74Pzi6MhDnYmOpWagPUo2prAbb4WSxRMAvk=,iv:mmqEICcoy7X5FP4e5uOvZdcoZHeAJFyod128KKvDK9s=,tag:jAokatZv5r3VM622/ceHJw==,type:str]
sops_unencrypted_suffix=_unencrypted
sops_version=3.12.2
diff --git a/.env-localdev.enc b/.env-localdev.enc
index fed9265ba1..f0ebc9a9b3 100644
--- a/.env-localdev.enc
+++ b/.env-localdev.enc
@@ -13,6 +13,8 @@ BACKFILL_QUEUE_MAX_MESSAGES=ENC[AES256_GCM,data:4ZYv,iv:d/BZ/me/FyfqzR4v1rmc49Cl
BACKFILL_QUEUE_WORKERS=ENC[AES256_GCM,data:lnNWVw==,iv:rYtkwNKXsUZ73JP+qqgjqkH6g4nWgswFPV3d4KydboA=,tag:5Tm6FxT+7deyI8WSudkR9A==,type:str]
BASE_URL=ENC[AES256_GCM,data:LUu9CaC23oMzyP3UtbCl04Ik2cEtda4=,iv:M80Oc/NekFuyk40wd8QNr6ArJFrTYejEQtR1b3Gnngg=,tag:rndkoVL+O0jN5modansumQ==,type:str]
BULK_UPLOAD_REQUESTS_TABLE=ENC[AES256_GCM,data:3mOP5vhUnGKANPie9wBPwq0=,iv:nTvJJ/p3cajOPR3Bf/r8dNg94284uR4GPZ8nf8W2G9U=,tag:LQd9kYAdk/e2GMA03WA4ag==,type:str]
+CAL_EVENT_TYPE_CONTENT_NAMES_KEY=ENC[AES256_GCM,data:rrEGULoFkh0L1YPQbv9sTbX8ciSdH2Lvx/vpjlbw2/qCCx9m97Fkrk0TLPiDP8ojeyM3H9Pkc+ZvusuRK6r+Xw==,iv:0wnJVJz1IplqPVX09dUCw4nwcFi2mpqlH7upTQM23ug=,tag:Q55S5KphmWLcwMMim8utww==,type:str]
+CAL_WEBHOOK_SECRET_KEY=ENC[AES256_GCM,data:KiYzyIfjxZpwBRB9uVe6khWJszW0eiW+RWmVbA==,iv:6nK8cmeiMvxoTeJrFBlj73PAhqCeuA94Zoiqdr4AGzc=,tag:Vsng1+XXC/bqoKVYhLARlg==,type:str]
CHAT_DELETE_QUEUE=ENC[AES256_GCM,data:uMGn+VHelaylz73/j3TP3P9qCMKnS2QOKd/Qt8arDA==,iv:R8jOUuPJXhDB+zTfRRQAWXN3KYNfE/tTbO/HPjTY7Nk=,tag:K3/KGKkw4RV5boYoRSiVsg==,type:str]
CONNECTION_GATEWAY_TABLE=ENC[AES256_GCM,data:UpVqapsnq/6JWBr8daSJ27UFb4ly/2XtwCQZ2KOZ7MgUlixRp78=,iv:U+qyhdIdhHdhpPVxj4kVmY3318QxyfvKCeLD0O3G2u0=,tag:CiB9VgW3/QZeiRsarCWxwQ==,type:str]
CONNECTION_GATEWAY_URL=ENC[AES256_GCM,data:W58EUPU5Ffx7aQneJzazq0cntxGX59tORLGSsqR+JMg=,iv:VyImOhURb34PjYXtia0tKi3BMb9yt7JMq19iNIpSvmo=,tag:cwe4uf3qqqK91h6d0Lo32w==,type:str]
@@ -78,6 +80,8 @@ MACRO_API_TOKEN_ISSUER=ENC[AES256_GCM,data:f2NW/9Pr6A==,iv:RGR5tVXc+95oB06ReTOV0
MACRO_API_TOKEN_PRIVATE_SECRET_KEY=ENC[AES256_GCM,data:EcgTOp9ev97FSae1lXJ3xRxdi42vdU1mGwPiEqYTzRy1t5PVtyZ0Rhgjxmq6KuO3C68DDww3a38pz7JgFia8nSKOYc8c1tR5JANoHQj13axtu+ndhAg5xku7PwW6IXREVocopt87CGvFS0okCykU3E3wKIDTxRv3AOdn+ZkCb1i8O+2Vp+Xp+DIq1xo0RyoezPDh3RlIBvFeXhmm4a4/5znpuW5blfxLZ9/+keMyPVR0SDbZZ36EuEB5Vq8ql++SuJcRiXJp5m2nRr4YtYmiiKYdHn3X5zrX1VfmELSdGdVLji+eyilSorCwmf6gQn0ijZE1pxav5dtCq5/uJ/oxeyfzeCOao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h48AUlZm9onh91c2HnlCuqS,iv:eBNoI9aiUT4RDZX+CVF5VttGbf3uUW3oeNJKkfq9xz4=,tag:i06RUAEpZ3LPe7bkAhztmg==,type:str]
+META_PIXEL_ID=ENC[AES256_GCM,data:FdqZKyZzOhMKLn0oFqpn1S0=,iv:aY3v0DIocP+A6Jtv5rNXezUc9WUdOt4tS4vX7jRMq7o=,tag:VgHjpIQQiQWo93lZuRfPvg==,type:str]
NOTIFICATIONS_ENABLED=ENC[AES256_GCM,data:2TaZi0vm,iv:dMqLOFANkcuVRFdqzUj3DaJpDQ3QS0rkdKaW5UKNZ9M=,tag:i4q5x+VWj5/N3y+U3jWr0Q==,type:str]
NOTIFICATION_QUEUE=ENC[AES256_GCM,data:gxtcU/dPX/qAzYEE5lwLTIi1nh+uIjLPVSrFBmTS84U=,iv:5oidzzrRSPFD2Oraohk23XNfit+1+j6pINjYKDuCh+o=,tag:VZJFscTw9RSbpz8gb9dDrg==,type:str]
OPENAI_API_KEY=ENC[AES256_GCM,data:aHDkd5VrbMj3+ZRt4dVdhb2K2FOd+QOnL9WBuApEtlqHHIbF0TqsvTQvjse/Zk0LSb5kmTXD+9SdPIKCwVwZ60mECZEmxmCA88XdWRdufUtyT8rIjFFHQrNvxUyL+5ta3zt62h/O0NpAaTfWgdA9CPIqk1guIRL/5uJbXPJHFx4Gk9EEx1ybKmbyNFGxSSkHBqUWmiQSVv/pr1JNXBNFG4o5D4bb+Q==,iv:/JmqEBhuXiZI7Sy0sY3ANyaQqflHOrV0f+M9FmgDH5g=,tag:03uEgCwWDHZy9E3lpnDDyQ==,type:str]
@@ -93,7 +97,7 @@ REDIS_RATE_LIMIT_REQS=ENC[AES256_GCM,data:NxGfm2vYuQ==,iv:kyoZbNsoS61ifQYIkGSYqw
REDIS_RATE_LIMIT_REQS_BACKFILL=ENC[AES256_GCM,data:ZLdtrWK07Q==,iv:n88QI1lJgA/o1Xp2Ce978pCXrq+eidxrW5vlWculLTA=,tag:CNd/haDAuOAhK24FZx063Q==,type:str]
REDIS_RATE_LIMIT_WINDOW_SECS=ENC[AES256_GCM,data:Hx/YoQ==,iv:X5X76Jw06AN5ydoRf6+I8kjE52x4iFeGGm3ecBIRDfw=,tag:CTMBzxhCSsyTXM1oCQs3Jw==,type:str]
REDIS_URI=ENC[AES256_GCM,data:Tfa4HlLcn520N5JHhEmCFQ/s50g=,iv:RSNqZXakL0yocKfYaJgh/AZbLbPu1u/RhVhNSBfw61w=,tag:RsjBD4/Y/JgsCShHa68U8g==,type:str]
-RUST_LOG=ENC[AES256_GCM,data:dWSxuo+5iw==,iv:/wTBLhU8qVrvmGVjP0ARPY0EnEopBOEOhyWOSMRWGY4=,tag:UD6eJqT2fR8Im1sKeB4BGQ==,type:str]
+RUST_LOG=ENC[AES256_GCM,data:/c7ZYxhN,iv:D+W8mrVzaEV7eZgy6tdNawpVJ3+xt+3pzqywGrUW99Y=,tag:iZvOJSo8+Zaagq04aBVBkQ==,type:str]
SEARCH_EVENT_QUEUE=ENC[AES256_GCM,data:cel0nmOnMeZePJOXpB0DfI2oHnIZ+Djp,iv:taag9pxl7UpI4kHJrAT8ThQeG6Z5+yhHr454xbitCBI=,tag:vLYasJHGUr12o2K0zPjFrw==,type:str]
SEARCH_PROCESSING_SERVICE_QUEUE_MAX_MESSAGES=ENC[AES256_GCM,data:TRVL3Q==,iv:hcT2YICCqzVgCIei1L4cN6sotJrzbcWq7J86xrUV7iQ=,tag:ki80B2WNQK+XGY1eVp09rg==,type:str]
SEARCH_PROCESSING_SERVICE_QUEUE_WAIT_TIME_SECONDS=ENC[AES256_GCM,data:zVlHMA==,iv:ChxGH/RqgxuBlRPWNU1bGUg6B0uVZ61Y8xTKh1Dn87w=,tag:M1Lsh5semx6NgmiLYcxoSQ==,type:str]
@@ -145,7 +149,7 @@ sops_kms__list_1__map_arn=arn:aws:kms:us-west-1:569036502058:key/mrk-cab29bf9480
sops_kms__list_1__map_aws_profile=
sops_kms__list_1__map_created_at=2026-03-03T19:32:17Z
sops_kms__list_1__map_enc=AQICAHjuYcSMsjB0lKJtZ3DIAvxF8N3RNRn5KZaAN74Et6122wHtcTS4UVhM79Eansn1/OmrAAAAfjB8BgkqhkiG9w0BBwagbzBtAgEAMGgGCSqGSIb3DQEHATAeBglghkgBZQMEAS4wEQQMRrFwSp99ZM2mPtJzAgEQgDvsIaiNifNz0/18C9OH77AG/LQLpmDiXiJYV46yLDv9vdyPL3PaLMvkAqgL3Xb2F4RcZOIUxkTS3u92xQ==
-sops_lastmodified=2026-04-07T15:42:38Z
-sops_mac=ENC[AES256_GCM,data:CNE5K7Bv2wHHgqnndbnJLx4/OEWQF3XCe2YJy7ddVQyIhiDWDBKG57OJwsquAJLNmpWzOTt1YC2v/hSIidQeUz136uCYtOXLZAnhxdy7xh92SSkAGXjaWq9Q9+WjUosQt8ATWgvmysSONoQ0XA5ODLYuZmiZ0DKFbok8H+2Ha3M=,iv:MzQJPgB/QoYTN8MpocacYx33h8eEp/lVsllONbhSRcA=,tag:8a3Dr+DCZ1EHkhZcVoYbbg==,type:str]
+sops_lastmodified=2026-04-22T17:23:57Z
+sops_mac=ENC[AES256_GCM,data:qQyalh9Zv1Ka2fUd9qcDAolppY7SVkyzmeEctoks7MOIPPP7OC7nJIlWG6Sp37iwHCXWLurT2cCptGQ0IjxraCpPQ+sPxlnrnW14wCQgNuB7iXZDVRtnb7Fi+Ul8CxUqTIUjGcnDPfyo2RFgnrpsshNuzudTTQKZNuUNx8/nYU4=,iv:xFx0W6lfwlztrq+I/BqVAzm2NnMY62utjizbhtX5sy0=,tag:sVdNixKv8TK7PLlaClS8Tw==,type:str]
sops_unencrypted_suffix=_unencrypted
sops_version=3.12.2
diff --git a/infra/stacks/cloud-storage-service/Pulumi.dev.yaml b/infra/stacks/cloud-storage-service/Pulumi.dev.yaml
index 52796d05d0..b70eaecdca 100644
--- a/infra/stacks/cloud-storage-service/Pulumi.dev.yaml
+++ b/infra/stacks/cloud-storage-service/Pulumi.dev.yaml
@@ -23,3 +23,7 @@ config:
cloud-storage-service:livekit_api_secret: livekit-api-secret-dev
cloud-storage-service:livekit_transcription_agent_name: macro-transcriber
cloud-storage-service:call_internal_secret: call-internal-secret-dev
+ cloud-storage-service:cal_webhook_secret_key: cal-webhook-secret-dev
+ cloud-storage-service:cal_event_type_content_names_key: cal-event-type-content-names-dev
+ cloud-storage-service:meta_pixel_id: "639142540393286"
+ cloud-storage-service:meta_access_token: meta-access-token
diff --git a/infra/stacks/cloud-storage-service/Pulumi.prod.yaml b/infra/stacks/cloud-storage-service/Pulumi.prod.yaml
index c58975e6c5..a09b6e1dd6 100644
--- a/infra/stacks/cloud-storage-service/Pulumi.prod.yaml
+++ b/infra/stacks/cloud-storage-service/Pulumi.prod.yaml
@@ -23,3 +23,7 @@ config:
cloud-storage-service:livekit_api_secret: livekit-api-secret-prod
cloud-storage-service:livekit_transcription_agent_name: macro-transcriber
cloud-storage-service:call_internal_secret: call-internal-secret-prod
+ cloud-storage-service:cal_webhook_secret_key: cal-webhook-secret-prod
+ cloud-storage-service:cal_event_type_content_names_key: cal-event-type-content-names-prod
+ cloud-storage-service:meta_pixel_id: "639142540393286"
+ cloud-storage-service:meta_access_token: meta-access-token
diff --git a/infra/stacks/cloud-storage-service/index.ts b/infra/stacks/cloud-storage-service/index.ts
index dd1a0088fb..0401a38c3a 100644
--- a/infra/stacks/cloud-storage-service/index.ts
+++ b/infra/stacks/cloud-storage-service/index.ts
@@ -281,6 +281,26 @@ const INTERNAL_CALL_SECRET = aws.secretsmanager
.getSecretVersionOutput({ secretId: config.require('call_internal_secret') })
.apply((secret) => secret.secretString);
+// Cal.com webhook — HMAC secret, resolved at runtime via Secrets Manager.
+const CAL_WEBHOOK_SECRET_KEY = config.require('cal_webhook_secret_key');
+const calWebhookSecretKeyArn: pulumi.Output<string> = aws.secretsmanager
+ .getSecretVersionOutput({ secretId: CAL_WEBHOOK_SECRET_KEY })
+ .apply((secret) => secret.arn);
+
+// Cal.com eventTypeId → Meta content_name JSON map, resolved at runtime.
+const CAL_EVENT_TYPE_CONTENT_NAMES_KEY = config.require(
+ 'cal_event_type_content_names_key'
+);
+const calEventTypeContentNamesKeyArn: pulumi.Output<string> = aws.secretsmanager
+ .getSecretVersionOutput({ secretId: CAL_EVENT_TYPE_CONTENT_NAMES_KEY })
+ .apply((secret) => secret.arn);
+
+// Meta Conversions API — feeds cal → Meta "Lead" events.
+const META_PIXEL_ID = config.require('meta_pixel_id');
+const META_ACCESS_TOKEN: pulumi.Output<string> = aws.secretsmanager
+ .getSecretVersionOutput({ secretId: config.require('meta_access_token') })
+ .apply((secret) => secret.secretString);
+
const callRecordingStack = new pulumi.StackReference('call-recording-stack', {
name: `macro-inc/call-recording/${stack}`,
});
@@ -345,6 +365,8 @@ const cloudStorageService = new CloudStorageService(
opensearchPasswordArn,
githubWebhookSecretKeyArn,
githubSyncAppPemArn,
+ calWebhookSecretKeyArn,
+ calEventTypeContentNamesKeyArn,
],
callRecordingCrudPolicyArn,
containerEnvVars: [
@@ -545,6 +567,23 @@ const cloudStorageService = new CloudStorageService(
name: 'GITHUB_SYNC_APP_CLIENT_ID',
value: GITHUB_SYNC_APP_CLIENT_ID,
},
+ // Cal.com webhook + Meta analytics
+ {
+ name: 'CAL_WEBHOOK_SECRET_KEY',
+ value: CAL_WEBHOOK_SECRET_KEY,
+ },
+ {
+ name: 'CAL_EVENT_TYPE_CONTENT_NAMES_KEY',
+ value: CAL_EVENT_TYPE_CONTENT_NAMES_KEY,
+ },
+ {
+ name: 'META_PIXEL_ID',
+ value: META_PIXEL_ID,
+ },
+ {
+ name: 'META_ACCESS_TOKEN',
+ value: pulumi.interpolate`${META_ACCESS_TOKEN}`,
+ },
// OpenTelemetry / Datadog tracing configuration
{
name: 'DD_SERVICE',
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 4e1810d62d..a35a259233 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -1751,6 +1751,25 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade8366b8bd5ba243f0a58f036cc0ca8a2f069cff1a2351ef1cac6b083e16fc0"
+[[package]]
+name = "cal"
+version = "0.1.0"
+dependencies = [
+ "analytics_client",
+ "axum",
+ "chrono",
+ "hex",
+ "hmac",
+ "model-error-response",
+ "rootcause",
+ "serde",
+ "serde_json",
+ "sha2",
+ "thiserror 2.0.17",
+ "tracing",
+ "utoipa",
+]
+
[[package]]
name = "call"
version = "0.1.0"
@@ -3129,6 +3148,7 @@ dependencies = [
name = "document_storage_service"
version = "0.1.0"
dependencies = [
+ "analytics_client",
"anyhow",
"aws-sdk-dynamodb",
"aws-sdk-s3",
@@ -3139,6 +3159,7 @@ dependencies = [
"base64 0.22.1",
"bytes",
"bzip2",
+ "cal",
"call",
"channels",
"chrono",
diff --git a/rust/cloud-storage/Cargo.toml b/rust/cloud-storage/Cargo.toml
index cd67ed8c7a..8fc8d1208e 100644
--- a/rust/cloud-storage/Cargo.toml
+++ b/rust/cloud-storage/Cargo.toml
@@ -11,6 +11,7 @@ members = [
"authentication_service",
"authentication_service_client",
"backfill_entity_access",
+ "cal",
"call",
"channels",
"chat",
diff --git a/rust/cloud-storage/analytics_client/src/providers/meta.rs b/rust/cloud-storage/analytics_client/src/providers/meta.rs
index 9cee6872b3..ffb5415add 100644
--- a/rust/cloud-storage/analytics_client/src/providers/meta.rs
+++ b/rust/cloud-storage/analytics_client/src/providers/meta.rs
@@ -32,6 +32,12 @@ pub struct MetaUserData {
pub fbc: Option<String>,
/// Facebook browser ID from `_fbp` cookie
pub fbp: Option<String>,
+ /// User agent of the browser session that triggered the conversion.
+ /// Sent raw (not hashed) per Meta's spec.
+ pub client_user_agent: Option<String>,
+ /// IP address of the browser session that triggered the conversion.
+ /// Sent raw (not hashed) per Meta's spec.
+ pub client_ip_address: Option<String>,
}
impl MetaUserData {
@@ -46,7 +52,7 @@ impl MetaUserData {
fn to_json(&self) -> serde_json::Value {
let mut data = serde_json::Map::new();
- if let Some(ref email) = self.email {
+ if let Some(email) = self.email.as_deref().filter(|s| !s.trim().is_empty()) {
data.insert("em".to_string(), serde_json::json!([hash_sha256(email)]));
}
if let Some(ref fbc) = self.fbc {
@@ -55,6 +61,12 @@ impl MetaUserData {
if let Some(ref fbp) = self.fbp {
data.insert("fbp".to_string(), serde_json::json!(fbp));
}
+ if let Some(ref ua) = self.client_user_agent {
+ data.insert("client_user_agent".to_string(), serde_json::json!(ua));
+ }
+ if let Some(ref ip) = self.client_ip_address {
+ data.insert("client_ip_address".to_string(), serde_json::json!(ip));
+ }
serde_json::Value::Object(data)
}
@@ -93,7 +105,7 @@ impl MetaProvider {
/// - `action_source`: Where the conversion originated
/// - `event_id`: Optional deduplication ID (recommended for server events)
/// - `custom_data`: Additional event data (will be serialized to JSON)
- #[tracing::instrument(skip(self, user_data, custom_data), err)]
+ #[tracing::instrument(skip(self, user_data, custom_data), err, fields(pixel_id = %self.pixel_id))]
pub async fn track(
&self,
event_name: &str,
@@ -119,6 +131,31 @@ impl MetaProvider {
event["event_id"] = serde_json::json!(id);
}
+ // Debug log of the outgoing event — only non-sensitive metadata and
+ // presence summaries. The full `event` payload is not logged
+ // because it can carry attribution cookies, IP, user_agent, and
+ // hashed PII that do not belong in centralized logs. Enable with
+ // `RUST_LOG=analytics_client=debug` to diagnose match quality.
+ let user_data_keys = event
+ .get("user_data")
+ .and_then(|v| v.as_object())
+ .map(|obj| obj.keys().cloned().collect::<Vec<_>>());
+ let custom_data_keys = event
+ .get("custom_data")
+ .and_then(|v| v.as_object())
+ .map(|obj| obj.keys().cloned().collect::<Vec<_>>());
+ tracing::debug!(
+ pixel_id = %self.pixel_id,
+ url = %url,
+ has_test_event_code = self.test_event_code.is_some(),
+ event_name = %event_name,
+ event_id = ?event_id,
+ action_source = %action_source.as_str(),
+ user_data_keys = ?user_data_keys,
+ custom_data_keys = ?custom_data_keys,
+ "sending event to meta conversions api"
+ );
+
let mut payload = serde_json::json!({
"data": [event],
"access_token": self.access_token,
@@ -128,12 +165,26 @@ impl MetaProvider {
payload["test_event_code"] = serde_json::json!(test_code);
}
- self.client
- .post(&url)
- .json(&payload)
- .send()
- .await?
- .error_for_status()?;
+ let response = self.client.post(&url).json(&payload).send().await?;
+ let status = response.status();
+ // Grab the status-based error while the response is still owned; then
+ // consume the body for logging.
+ let status_error = response.error_for_status_ref().err();
+ let body = response.text().await.unwrap_or_default();
+
+ // Meta returns interesting JSON in the body on 2xx too — e.g.
+ // `events_received`, `fbtrace_id`, and warnings about match quality
+ // or missing fields. Kept at debug so production logs don't carry
+ // the full body on every Lead fire.
+ tracing::debug!(
+ status = %status,
+ body = %body,
+ "meta conversions api response"
+ );
+
+ if let Some(e) = status_error {
+ return Err(e);
+ }
Ok(())
}
diff --git a/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rs b/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rs
index 2f5e2abf3a..7ffc6827ba 100644
--- a/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rs
+++ b/rust/cloud-storage/authentication_service/src/api/webhooks/user/stripe_webhook.rs
@@ -540,6 +540,7 @@ fn track_stripe_subscription(
email: Some(data.email.clone()),
fbp: data.fbp.clone(),
fbc: data.fbc.clone(),
+ ..MetaUserData::default()
};
let event_id = Some(subscription_id.as_str());
diff --git a/rust/cloud-storage/cal/Cargo.toml b/rust/cloud-storage/cal/Cargo.toml
new file mode 100644
index 0000000000..f4a2245390
--- /dev/null
+++ b/rust/cloud-storage/cal/Cargo.toml
@@ -0,0 +1,25 @@
+[package]
+edition = "2024"
+name = "cal"
+publish = false
+version = "0.1.0"
+
+[features]
+all = ["axum", "outbound"]
+axum = ["dep:axum", "dep:model-error-response", "dep:utoipa"]
+outbound = ["dep:analytics_client"]
+
+[dependencies]
+analytics_client = { path = "../analytics_client", optional = true }
+axum = { workspace = true, optional = true }
+chrono = { workspace = true, features = ["serde"] }
+hex = { workspace = true }
+hmac = { workspace = true }
+model-error-response = { path = "../model-error-response", optional = true }
+rootcause = { workspace = true }
+serde = { workspace = true }
+serde_json = { workspace = true }
+sha2 = { workspace = true }
+thiserror = { workspace = true }
+tracing = { workspace = true }
+utoipa = { workspace = true, optional = true }
diff --git a/rust/cloud-storage/cal/src/domain.rs b/rust/cloud-storage/cal/src/domain.rs
new file mode 100644
index 0000000000..608f92d43c
--- /dev/null
+++ b/rust/cloud-storage/cal/src/domain.rs
@@ -0,0 +1,5 @@
+//! Domain layer for the cal.com integration.
+
+pub mod models;
+pub mod ports;
+pub mod service;
diff --git a/rust/cloud-storage/cal/src/domain/models.rs b/rust/cloud-storage/cal/src/domain/models.rs
new file mode 100644
index 0000000000..847d161975
--- /dev/null
+++ b/rust/cloud-storage/cal/src/domain/models.rs
@@ -0,0 +1,129 @@
+//! Core domain models for cal.com webhook processing.
+
+use std::collections::HashMap;
+
+use chrono::{DateTime, Utc};
+use serde::Deserialize;
+use thiserror::Error;
+
+/// A validated cal.com webhook event.
+///
+/// Produced by [`crate::domain::ports::CalWebhookService::validate_webhook_event`]
+/// after signature verification and JSON parsing.
+#[derive(Debug, Clone)]
+pub enum CalWebhookEvent {
+ /// A new booking was created.
+ BookingCreated(BookingCreated),
+}
+
+/// Payload for the `BOOKING_CREATED` cal.com webhook event.
+///
+/// This mirrors the fields cal.com actually sends; fields we don't yet use are
+/// omitted rather than stubbed so they can be added deliberately.
+#[derive(Debug, Clone, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct BookingCreated {
+ /// Unique identifier for the booking (uuid-like string from cal.com).
+ pub uid: String,
+ /// Numeric booking id from cal.com.
+ pub booking_id: Option<u64>,
+ /// Title of the booking (e.g. "30 Min Meeting between A and B").
+ pub title: String,
+ /// Start time of the booking.
+ pub start_time: DateTime<Utc>,
+ /// End time of the booking.
+ pub end_time: DateTime<Utc>,
+ /// Event type id configured in cal.com (i.e. which meeting template).
+ pub event_type_id: Option<u64>,
+ /// The organizer of the booking (the cal.com user who owns the event type).
+ pub organizer: CalContact,
+ /// People invited to the booking.
+ #[serde(default)]
+ pub attendees: Vec<CalContact>,
+ /// Optional location string (zoom link, address, etc.).
+ pub location: Option<String>,
+ /// Free-form metadata forwarded from the booking URL or embed config.
+ ///
+ /// We stash browser-side Meta attribution signals here (`fbp`, `fbc`,
+ /// `user_agent`) so the server-side Lead event can include them in
+ /// `user_data` when it fires.
+ ///
+ /// Typed as `serde_json::Value` rather than `String` because cal.com
+ /// documents this field as a JSON object with provider-specific data
+ /// (e.g. `videoCallUrl`) — values aren't guaranteed to be strings.
+ /// Downstream consumers narrow per-key with `v.as_str()`.
+ #[serde(default)]
+ pub metadata: HashMap<String, serde_json::Value>,
+}
+
+/// A cal.com contact — used for both organizers and attendees.
+#[derive(Debug, Clone, Deserialize)]
+pub struct CalContact {
+ /// Contact email address.
+ pub email: String,
+ /// Display name, if cal.com provided one.
+ #[serde(default)]
+ pub name: Option<String>,
+ /// IANA time zone string (e.g. `"America/New_York"`).
+ #[serde(default, rename = "timeZone")]
+ pub time_zone: Option<String>,
+}
+
+/// The raw top-level envelope cal.com posts for every webhook.
+///
+/// We deserialize into this first, then route on [`CalTriggerEvent`] to
+/// produce the strongly-typed [`CalWebhookEvent`].
+#[derive(Debug, Clone, Deserialize)]
+pub struct CalWebhookEnvelope {
+ /// The event type cal.com is notifying us about.
+ #[serde(rename = "triggerEvent")]
+ pub trigger_event: String,
+ /// The event payload. Shape varies per `triggerEvent`.
+ pub payload: serde_json::Value,
+}
+
+/// Supported cal.com trigger events.
+///
+/// Unknown events are preserved as-is so callers can log + skip without
+/// failing deserialization.
+#[derive(Debug, Clone)]
+pub enum CalTriggerEvent {
+ /// `BOOKING_CREATED`.
+ BookingCreated,
+ /// Any trigger event this crate does not yet handle.
+ Unsupported(String),
+}
+
+impl CalTriggerEvent {
+ /// Parse the cal.com `triggerEvent` string.
+ pub fn parse(raw: &str) -> Self {
+ match raw {
+ "BOOKING_CREATED" => Self::BookingCreated,
+ other => Self::Unsupported(other.to_string()),
+ }
+ }
+}
+
+/// Errors returned by the cal.com domain.
+#[derive(Debug, Error)]
+pub enum CalError {
+ /// The `X-Cal-Signature-256` header was missing, malformed, or did not
+ /// match the computed HMAC.
+ #[error("invalid webhook signature")]
+ InvalidWebhookSignature,
+ /// The webhook body was not valid JSON matching the expected shape.
+ #[error("invalid webhook payload")]
+ InvalidPayload,
+ /// The webhook was structurally valid but we do not handle its event type.
+ #[error("unsupported cal trigger event: {0}")]
+ UnsupportedEvent(String),
+ /// An internal error occurred (analytics sink failure, unexpected state).
+ #[error("internal cal error: {0:?}")]
+ Internal(rootcause::Report),
+}
+
+impl From<rootcause::Report> for CalError {
+ fn from(report: rootcause::Report) -> Self {
+ CalError::Internal(report)
+ }
+}
diff --git a/rust/cloud-storage/cal/src/domain/ports.rs b/rust/cloud-storage/cal/src/domain/ports.rs
new file mode 100644
index 0000000000..d75e40a19e
--- /dev/null
+++ b/rust/cloud-storage/cal/src/domain/ports.rs
@@ -0,0 +1,45 @@
+//! Port definitions for the cal.com integration.
+
+use std::future::Future;
+
+use rootcause::Report;
+
+use crate::domain::models::{BookingCreated, CalError, CalWebhookEvent};
+
+/// Service that validates and processes cal.com webhook events.
+///
+/// The inbound HTTP adapter drives this trait.
+pub trait CalWebhookService: Send + Sync + 'static {
+ /// Verify the HMAC signature on a webhook body and parse its event.
+ ///
+ /// Returns [`CalError::InvalidWebhookSignature`] on signature mismatch
+ /// and [`CalError::InvalidPayload`] when the body is not valid JSON.
+ fn validate_webhook_event(
+ &self,
+ signature: &str,
+ body: &[u8],
+ ) -> impl Future<Output = Result<CalWebhookEvent, CalError>> + Send;
+
+ /// Dispatch a validated webhook event to the configured analytics sink.
+ fn process_webhook_event(
+ &self,
+ event: &CalWebhookEvent,
+ ) -> impl Future<Output = Result<(), CalError>> + Send;
+}
+
+/// Outbound port: fires analytics events produced by the cal.com domain.
+///
+/// Implementations live under [`crate::outbound`]; the default adapter wraps
+/// `analytics_client::AnalyticsClient`.
+pub trait AnalyticsSink: Send + Sync + 'static {
+ /// Track a `BOOKING_CREATED` event.
+ ///
+ /// `content_name` is the Meta `content_name` attribute resolved from the
+ /// booking's `eventTypeId` by the service layer — see
+ /// [`crate::domain::service::CalConfig::event_type_content_names`].
+ fn on_booking_created(
+ &self,
+ booking: &BookingCreated,
+ content_name: &str,
+ ) -> impl Future<Output = Result<(), Report>> + Send;
+}
diff --git a/rust/cloud-storage/cal/src/domain/service.rs b/rust/cloud-storage/cal/src/domain/service.rs
new file mode 100644
index 0000000000..d7a9dc8b6e
--- /dev/null
+++ b/rust/cloud-storage/cal/src/domain/service.rs
@@ -0,0 +1,113 @@
+//! Cal.com webhook service implementation.
+
+use std::collections::HashMap;
+
+use hmac::{Hmac, Mac};
+use sha2::Sha256;
+
+use crate::domain::models::{
+ BookingCreated, CalError, CalTriggerEvent, CalWebhookEnvelope, CalWebhookEvent,
+};
+use crate::domain::ports::{AnalyticsSink, CalWebhookService};
+
+type HmacSha256 = Hmac<Sha256>;
+
+/// Configuration for the cal.com webhook service.
+#[derive(Debug, Clone)]
+pub struct CalConfig {
+ /// Shared secret configured on the cal.com webhook. Used to verify the
+ /// HMAC-SHA256 signature in `X-Cal-Signature-256`.
+ pub webhook_secret: String,
+ /// Maps cal.com `eventTypeId` to the Meta `content_name` we fire for it.
+ ///
+ /// Bookings whose event type id is absent from this map are logged and
+ /// skipped: we'd rather miss a Lead than fire an unlabeled one when
+ /// someone adds a new event type in cal.com.
+ pub event_type_content_names: HashMap<u64, String>,
+}
+
+/// Concrete cal.com webhook service.
+///
+/// Generic over an [`AnalyticsSink`] so the outbound adapter can be swapped
+/// (production: `analytics_client`; tests: a mock).
+pub struct CalWebhookServiceImpl<A> {
+ config: CalConfig,
+ analytics: A,
+}
+
+impl<A> CalWebhookServiceImpl<A> {
+ /// Create a new service.
+ pub fn new(config: CalConfig, analytics: A) -> Self {
+ Self { config, analytics }
+ }
+}
+
+impl<A: AnalyticsSink> CalWebhookService for CalWebhookServiceImpl<A> {
+ #[tracing::instrument(err, skip(self, body))]
+ async fn validate_webhook_event(
+ &self,
+ signature: &str,
+ body: &[u8],
+ ) -> Result<CalWebhookEvent, CalError> {
+ let sig_bytes = hex::decode(signature).map_err(|_| CalError::InvalidWebhookSignature)?;
+
+ let mut mac = HmacSha256::new_from_slice(self.config.webhook_secret.as_bytes())
+ .map_err(|e| CalError::Internal(rootcause::report!("invalid webhook secret: {e}")))?;
+ mac.update(body);
+ mac.verify_slice(&sig_bytes)
+ .map_err(|_| CalError::InvalidWebhookSignature)?;
+
+ let envelope: CalWebhookEnvelope =
+ serde_json::from_slice(body).map_err(|_| CalError::InvalidPayload)?;
+
+ // Log every authenticated webhook, even ones we don't yet handle, so
+ // absence of handling is observable (unsupported events short-circuit
+ // below with 204, bypassing the handler).
+ tracing::info!(trigger_event = %envelope.trigger_event, "received cal webhook");
+
+ match CalTriggerEvent::parse(&envelope.trigger_event) {
+ CalTriggerEvent::BookingCreated => {
+ let booking: BookingCreated =
+ serde_json::from_value(envelope.payload).map_err(|e| {
+ tracing::warn!(error=?e, "failed to parse BOOKING_CREATED payload");
+ CalError::InvalidPayload
+ })?;
+ Ok(CalWebhookEvent::BookingCreated(booking))
+ }
+ CalTriggerEvent::Unsupported(raw) => Err(CalError::UnsupportedEvent(raw)),
+ }
+ }
+
+ #[tracing::instrument(err, skip(self, event))]
+ async fn process_webhook_event(&self, event: &CalWebhookEvent) -> Result<(), CalError> {
+ match event {
+ CalWebhookEvent::BookingCreated(booking) => {
+ let Some(event_type_id) = booking.event_type_id else {
+ tracing::warn!(uid = %booking.uid, "cal booking missing eventTypeId, skipping analytics");
+ return Ok(());
+ };
+
+ let Some(content_name) = self.config.event_type_content_names.get(&event_type_id)
+ else {
+ tracing::warn!(
+ uid = %booking.uid,
+ event_type_id,
+ "unmapped cal eventTypeId, skipping analytics",
+ );
+ return Ok(());
+ };
+
+ tracing::info!(
+ uid = %booking.uid,
+ event_type_id,
+ content_name = %content_name,
+ "processing cal BOOKING_CREATED",
+ );
+ self.analytics
+ .on_booking_created(booking, content_name)
+ .await?;
+ Ok(())
+ }
+ }
+ }
+}
diff --git a/rust/cloud-storage/cal/src/inbound.rs b/rust/cloud-storage/cal/src/inbound.rs
new file mode 100644
index 0000000000..095ed28814
--- /dev/null
+++ b/rust/cloud-storage/cal/src/inbound.rs
@@ -0,0 +1,41 @@
+//! Inbound adapters for the cal.com integration.
+
+pub mod cal_webhook_router;
+
+use axum::{
+ Json,
+ http::StatusCode,
+ response::{IntoResponse, Response},
+};
+use model_error_response::ErrorResponse;
+
+use crate::domain::models::CalError;
+
+impl IntoResponse for CalError {
+ fn into_response(self) -> Response {
+ let (status, message): (StatusCode, &str) = match &self {
+ CalError::InvalidWebhookSignature => (StatusCode::UNAUTHORIZED, "unauthenticated"),
+ CalError::InvalidPayload => {
+ tracing::warn!("cal webhook: invalid payload");
+ (StatusCode::BAD_REQUEST, "invalid webhook payload")
+ }
+ // Unsupported events get a 2xx so cal.com doesn't retry them.
+ CalError::UnsupportedEvent(_) => return StatusCode::NO_CONTENT.into_response(),
+ CalError::Internal(e) => {
+ tracing::error!(error=?e, "cal webhook: internal error");
+ (
+ StatusCode::INTERNAL_SERVER_ERROR,
+ "internal server error occurred",
+ )
+ }
+ };
+
+ (
+ status,
+ Json(ErrorResponse {
+ message: message.into(),
+ }),
+ )
+ .into_response()
+ }
+}
diff --git a/rust/cloud-storage/cal/src/inbound/cal_webhook_router/mod.rs b/rust/cloud-storage/cal/src/inbound/cal_webhook_router/mod.rs
new file mode 100644
index 0000000000..2b336eae7e
--- /dev/null
+++ b/rust/cloud-storage/cal/src/inbound/cal_webhook_router/mod.rs
@@ -0,0 +1,104 @@
+//! Cal.com webhook HTTP router.
+//!
+//! Provides:
+//! - `POST /webhook` — receives cal.com webhook events. The body is validated
+//! against the `X-Cal-Signature-256` HMAC-SHA256 header using the shared
+//! webhook secret, then dispatched through the [`CalWebhookService`].
+
+use std::sync::Arc;
+
+use axum::{
+ Router,
+ extract::{FromRequest, Request, State},
+ http::StatusCode,
+ routing::post,
+};
+
+use crate::domain::{models::CalError, ports::CalWebhookService};
+
+/// Maximum accepted cal.com webhook body size. Cal payloads carrying a full
+/// booking event are comfortably under this; the cap exists so an
+/// unauthenticated caller with any signature header cannot force the service
+/// to buffer arbitrary bytes before signature verification happens.
+const MAX_CAL_WEBHOOK_BODY_BYTES: usize = 1024 * 1024;
+
+/// Shared state passed to cal webhook handlers.
+pub struct CalWebhookRouterState<S> {
+ /// The webhook service implementation.
+ pub service: Arc<S>,
+}
+
+impl<S> Clone for CalWebhookRouterState<S> {
+ fn clone(&self) -> Self {
+ Self {
+ service: Arc::clone(&self.service),
+ }
+ }
+}
+
+impl<S: CalWebhookService> CalWebhookRouterState<S> {
+ /// Construct a new state from a webhook service.
+ pub fn new(service: S) -> Self {
+ Self {
+ service: Arc::new(service),
+ }
+ }
+}
+
+/// Build the cal.com webhook router.
+pub fn cal_webhook_router<S, T>(state: CalWebhookRouterState<S>) -> Router<T>
+where
+ S: CalWebhookService,
+ T: Send + Sync + Clone + 'static,
+{
+ Router::new()
+ .route("/webhook", post(cal_webhook_handler::<S>))
+ .with_state(state)
+}
+
+/// Extractor that reads the raw request body, verifies the
+/// `X-Cal-Signature-256` header against the configured webhook secret, and
+/// parses the body into a [`crate::domain::models::CalWebhookEvent`].
+pub struct CalWebhookEventExtractor(pub crate::domain::models::CalWebhookEvent);
+
+impl<S> FromRequest<CalWebhookRouterState<S>> for CalWebhookEventExtractor
+where
+ S: CalWebhookService,
+{
+ type Rejection = CalError;
+
+ async fn from_request(
+ req: Request,
+ state: &CalWebhookRouterState<S>,
+ ) -> Result<Self, Self::Rejection> {
+ let (parts, body) = req.into_parts();
+
+ let signature = parts
+ .headers
+ .get("X-Cal-Signature-256")
+ .and_then(|v| v.to_str().ok())
+ .ok_or(CalError::InvalidWebhookSignature)?;
+
+ let body = axum::body::to_bytes(body, MAX_CAL_WEBHOOK_BODY_BYTES)
+ .await
+ .map_err(|_| CalError::InvalidPayload)?;
+
+ let event = state
+ .service
+ .validate_webhook_event(signature, &body)
+ .await?;
+
+ Ok(CalWebhookEventExtractor(event))
+ }
+}
+
+/// Entrypoint for cal.com webhook events.
+#[tracing::instrument(err, skip(state, event))]
+pub async fn cal_webhook_handler<S: CalWebhookService>(
+ State(state): State<CalWebhookRouterState<S>>,
+ CalWebhookEventExtractor(event): CalWebhookEventExtractor,
+) -> Result<StatusCode, CalError> {
+ tracing::info!("cal_webhook");
+ state.service.process_webhook_event(&event).await?;
+ Ok(StatusCode::OK)
+}
diff --git a/rust/cloud-storage/cal/src/lib.rs b/rust/cloud-storage/cal/src/lib.rs
new file mode 100644
index 0000000000..34a7dbac1f
--- /dev/null
+++ b/rust/cloud-storage/cal/src/lib.rs
@@ -0,0 +1,20 @@
+//! Cal.com integration library.
+//!
+//! Receives cal.com webhook events (booking created, etc.) and fires
+//! analytics events in response. Follows the hexagonal architecture
+//! pattern used elsewhere in the workspace:
+//!
+//! - [`domain`]: core models, ports, and the webhook service
+//! - [`inbound`]: HTTP router that validates and dispatches cal.com webhooks
+//! - [`outbound`]: adapters that ship domain events to analytics backends
+
+#![deny(missing_docs)]
+
+/// Domain layer: models, ports, and the webhook service.
+pub mod domain;
+/// Inbound adapters (HTTP router for cal.com webhooks).
+#[cfg(feature = "axum")]
+pub mod inbound;
+/// Outbound adapters (analytics sinks).
+#[cfg(feature = "outbound")]
+pub mod outbound;
diff --git a/rust/cloud-storage/cal/src/outbound.rs b/rust/cloud-storage/cal/src/outbound.rs
new file mode 100644
index 0000000000..1333f0bdae
--- /dev/null
+++ b/rust/cloud-storage/cal/src/outbound.rs
@@ -0,0 +1,3 @@
+//! Outbound adapters for the cal.com integration.
+
+pub mod analytics_client;
diff --git a/rust/cloud-storage/cal/src/outbound/analytics_client.rs b/rust/cloud-storage/cal/src/outbound/analytics_client.rs
new file mode 100644
index 0000000000..b79ca3e603
--- /dev/null
+++ b/rust/cloud-storage/cal/src/outbound/analytics_client.rs
@@ -0,0 +1,106 @@
+//! [`AnalyticsSink`](crate::domain::ports::AnalyticsSink) adapter over
+//! `analytics_client::AnalyticsClient`.
+//!
+//! For `BOOKING_CREATED` this fires a Meta "Lead" event keyed on the first
+//! attendee's email. `content_name` is resolved by the service from the
+//! booking's `eventTypeId`.
+
+use std::sync::Arc;
+
+use analytics_client::{AnalyticsClient, MetaActionSource, MetaUserData};
+use rootcause::Report;
+use serde::Serialize;
+
+use crate::domain::models::BookingCreated;
+use crate::domain::ports::AnalyticsSink;
+
+/// Analytics sink backed by `analytics_client::AnalyticsClient`.
+pub struct AnalyticsClientSink {
+ client: Arc<AnalyticsClient>,
+}
+
+impl AnalyticsClientSink {
+ /// Construct a new sink from a shared analytics client.
+ pub fn new(client: Arc<AnalyticsClient>) -> Self {
+ Self { client }
+ }
+}
+
+#[derive(Debug, Serialize)]
+struct LeadCustomData<'a> {
+ content_name: &'a str,
+ content_category: &'static str,
+}
+
+impl AnalyticsSink for AnalyticsClientSink {
+ #[tracing::instrument(
+ err,
+ skip(self, booking),
+ fields(uid = %booking.uid, content_name),
+ )]
+ async fn on_booking_created(
+ &self,
+ booking: &BookingCreated,
+ content_name: &str,
+ ) -> Result<(), Report> {
+ let attendee_email = booking.attendees.first().map(|a| a.email.as_str());
+
+ // Attribution signals passed through from the marketing site via
+ // `?metadata[...]=` URL params (link flow) or `config.metadata` on
+ // the cal embed (embed flow). Without these, Meta can only match on
+ // hashed email, which is why the custom-conversion counter wasn't
+ // moving for real bookings.
+ let metadata = &booking.metadata;
+
+ let user_data = MetaUserData {
+ email: attendee_email.map(str::to_string),
+ fbp: metadata
+ .get("fbp")
+ .and_then(|v| v.as_str())
+ .map(str::to_owned),
+ fbc: metadata
+ .get("fbc")
+ .and_then(|v| v.as_str())
+ .map(str::to_owned),
+ client_user_agent: metadata
+ .get("user_agent")
+ .and_then(|v| v.as_str())
+ .map(str::to_owned),
+ ..MetaUserData::default()
+ };
+
+ let custom_data = LeadCustomData {
+ content_name,
+ content_category: "cal_booking",
+ };
+
+ // Debug log so we can see whether cal.com's metadata passthrough is
+ // carrying the browser attribution signals. Only presence flags and
+ // metadata key names are emitted — the raw email, fbp/fbc values,
+ // and user_agent are deliberately not logged to avoid PII leakage.
+ // Enable with `RUST_LOG=cal=debug` when investigating match quality.
+ tracing::debug!(
+ uid = %booking.uid,
+ content_name = %content_name,
+ metadata_keys = ?metadata.keys().collect::<Vec<_>>(),
+ has_email = user_data.email.is_some(),
+ has_fbp = user_data.fbp.is_some(),
+ has_fbc = user_data.fbc.is_some(),
+ has_client_user_agent = user_data.client_user_agent.is_some(),
+ "preparing meta Lead from cal BOOKING_CREATED"
+ );
+
+ self.client
+ .track_meta(
+ "Lead",
+ &user_data,
+ MetaActionSource::Website,
+ Some(&booking.uid),
+ &custom_data,
+ )
+ .await
+ .map_err(|e| rootcause::report!("meta track failed: {e}"))?;
+
+ Ok(())
+ }
+}
diff --git a/rust/cloud-storage/deny.toml b/rust/cloud-storage/deny.toml
index fc5db10b8a..34b8360b5d 100644
--- a/rust/cloud-storage/deny.toml
+++ b/rust/cloud-storage/deny.toml
@@ -77,6 +77,8 @@ ignore = [
{ id = "RUSTSEC-2025-0057", reason = "We should switch to rustc-hash, but haven't got to that yet" },
{ id = "RUSTSEC-2026-0098", reason = "rustls-webpki 0.101.7 pinned by AWS SDK via rustls 0.21" },
{ id = "RUSTSEC-2026-0099", reason = "rustls-webpki 0.101.7 pinned by AWS SDK via rustls 0.21" },
+ { id = "RUSTSEC-2026-0104", reason = "rustls-webpki 0.101.7 pinned by AWS SDK via rustls 0.21" },
+ { id = "RUSTSEC-2026-0105", reason = "core2 yanked/unmaintained, transitive via pdfium-render deps" },
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
#"[email protected]", # you can also ignore yanked crate versions if you wish
#{ crate = "[email protected]", reason = "you can specify why you are ignoring the yanked crate" },
diff --git a/rust/cloud-storage/document_storage_service/Cargo.toml b/rust/cloud-storage/document_storage_service/Cargo.toml
index e75356f02e..50afd6e72f 100644
--- a/rust/cloud-storage/document_storage_service/Cargo.toml
+++ b/rust/cloud-storage/document_storage_service/Cargo.toml
@@ -37,6 +37,8 @@ bytes = { workspace = true }
bzip2 = { workspace = true, default-features = false, features = [
"libbz2-rs-sys",
] }
+analytics_client = { path = "../analytics_client" }
+cal = { path = "../cal", features = ["axum", "outbound"] }
call = { path = "../call" }
channels = { path = "../channels", features = ["inbound", "outbound"] }
chrono = { workspace = true }
diff --git a/rust/cloud-storage/document_storage_service/src/api/context.rs b/rust/cloud-storage/document_storage_service/src/api/context.rs
index a837c3b154..764905df02 100644
--- a/rust/cloud-storage/document_storage_service/src/api/context.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/context.rs
@@ -1,5 +1,9 @@
use crate::{config::Config, service::s3::S3};
use axum::extract::FromRef;
+use cal::{
+ domain::service::CalWebhookServiceImpl, inbound::cal_webhook_router::CalWebhookRouterState,
+ outbound::analytics_client::AnalyticsClientSink,
+};
use call::{
domain::service::CallServiceImpl,
inbound::axum_router::{CallRouterState, InternalCallRouterState, WebhookRouterState},
@@ -206,6 +210,12 @@ pub(crate) type DssCallInternalState = InternalCallRouterState<DssCallService>;
pub(crate) type GithubSyncServiceType =
GithubSyncServiceImpl<DocumentService, PgGithubSyncRepo, GithubSyncClientImpl>;
+/// Type alias for the cal.com webhook service.
+pub(crate) type CalWebhookServiceType = CalWebhookServiceImpl<AnalyticsClientSink>;
+
+/// Type alias for the cal.com webhook router state.
+pub(crate) type DssCalWebhookState = CalWebhookRouterState<CalWebhookServiceType>;
+
#[derive(Clone, FromRef)]
pub(crate) struct ApiContext {
pub db: PgPool,
@@ -237,6 +247,7 @@ pub(crate) struct ApiContext {
pub call_state: DssCallState,
pub call_webhook_state: DssCallWebhookState,
pub call_internal_state: DssCallInternalState,
+ pub cal_webhook_state: DssCalWebhookState,
pub entity_access_management_service: EntityAccessManagementService,
}
diff --git a/rust/cloud-storage/document_storage_service/src/api/mod.rs b/rust/cloud-storage/document_storage_service/src/api/mod.rs
index 301599a1b0..97618c29dd 100644
--- a/rust/cloud-storage/document_storage_service/src/api/mod.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/mod.rs
@@ -92,11 +92,17 @@ fn api_router(state: ApiContext) -> Router {
service: state.github_sync_service.clone(),
};
- // Webhook router is outside auth — LiveKit validates via its own JWT.
- let webhook_router = Router::new().nest(
- "/call",
- call::inbound::axum_router::webhook_router(state.call_webhook_state.clone()),
- );
+ // Webhook router is outside auth — LiveKit validates via its own JWT,
+ // cal.com validates via HMAC signature.
+ let webhook_router = Router::new()
+ .nest(
+ "/call",
+ call::inbound::axum_router::webhook_router(state.call_webhook_state.clone()),
+ )
+ .nest(
+ "/cal",
+ cal::inbound::cal_webhook_router::cal_webhook_router(state.cal_webhook_state.clone()),
+ );
// Internal call router — agent-authenticated via x-macro-internal-call header.
let internal_call_router = Router::new().nest(
diff --git a/rust/cloud-storage/document_storage_service/src/config.rs b/rust/cloud-storage/document_storage_service/src/config.rs
index 7366365308..bed87e1be9 100644
--- a/rust/cloud-storage/document_storage_service/src/config.rs
+++ b/rust/cloud-storage/document_storage_service/src/config.rs
@@ -111,6 +111,35 @@ env_var! {
pub struct GithubSyncAppPemSecretKey;
}
+env_var! {
+ pub struct CalWebhookSecretKey;
+}
+
+env_var! {
+ /// Secrets Manager secret name holding the JSON map from cal.com
+ /// `eventTypeId` to Meta `content_name`.
+ pub struct CalEventTypeContentNamesKey;
+}
+
+env_var! {
+ /// Meta (Facebook) Conversions API pixel id. Required — pair with
+ /// [`MetaAccessToken`] for cal → Meta Lead tracking. Set to a dummy
+ /// value locally; it's only exercised when a cal webhook fires.
+ pub struct MetaPixelId;
+}
+
+env_var! {
+ /// Meta (Facebook) Conversions API access token. Required — see
+ /// [`MetaPixelId`].
+ pub struct MetaAccessToken;
+}
+
+maybe_env_var! {
+ /// Optional Meta test event code — routes events to Meta's test events
+ /// view instead of production tracking.
+ pub struct MetaTestEventCode;
+}
+
impl Config {
pub fn from_env(
document_storage_service_cloudfront_signer_private_key: LocalOrRemoteSecret<
diff --git a/rust/cloud-storage/document_storage_service/src/main.rs b/rust/cloud-storage/document_storage_service/src/main.rs
index a507d6bf60..9aa913e5aa 100644
--- a/rust/cloud-storage/document_storage_service/src/main.rs
+++ b/rust/cloud-storage/document_storage_service/src/main.rs
@@ -2,12 +2,19 @@
use crate::{
api::context::{ApiContext, DocumentStorageServiceAuthKey, TaskPropertiesAdapter},
config::{
- DocumentPermissionJwtSecretKey, DocumentStorageServiceCloudfrontSignerPrivateKeySecretName,
- GithubSyncAppPemSecretKey, GithubWebhookSecretKey,
+ CalEventTypeContentNamesKey, CalWebhookSecretKey, DocumentPermissionJwtSecretKey,
+ DocumentStorageServiceCloudfrontSignerPrivateKeySecretName, GithubSyncAppPemSecretKey,
+ GithubWebhookSecretKey, MetaAccessToken, MetaPixelId, MetaTestEventCode,
},
service::s3::S3,
};
+use analytics_client::{AnalyticsClient, AnalyticsClientConfig, MetaConfig};
use anyhow::Context;
+use cal::{
+ domain::service::{CalConfig, CalWebhookServiceImpl},
+ inbound::cal_webhook_router::CalWebhookRouterState,
+ outbound::analytics_client::AnalyticsClientSink,
+};
use call::{
domain::service::CallServiceImpl,
inbound::axum_router::{CallRouterState, InternalCallRouterState, WebhookRouterState},
@@ -356,6 +363,37 @@ async fn main() -> anyhow::Result<()> {
GithubSyncClientImpl::default(),
);
+ // Cal.com webhooks → Meta Lead events. Both secrets are loaded here
+ // (rather than on Config) to keep cal/Meta wiring colocated.
+ let cal_webhook_secret = secretsmanager_client
+ .get_maybe_secret_value(env, CalWebhookSecretKey::new()?)
+ .await?;
+ let cal_event_type_content_names_secret = secretsmanager_client
+ .get_maybe_secret_value(env, CalEventTypeContentNamesKey::new()?)
+ .await?;
+
+ let analytics_client = Arc::new(AnalyticsClient::new(AnalyticsClientConfig {
+ google_analytics: None,
+ meta: Some(MetaConfig {
+ pixel_id: MetaPixelId::new()?.as_ref().to_string(),
+ access_token: MetaAccessToken::new()?.as_ref().to_string(),
+ test_event_code: MetaTestEventCode::new().map(|v| v.as_ref().to_string()),
+ }),
+ posthog: None,
+ }));
+
+ let cal_event_type_content_names: std::collections::HashMap<u64, String> =
+ serde_json::from_str(cal_event_type_content_names_secret.as_ref())
+ .context("CalEventTypeContentNames secret must be a JSON object mapping eventTypeId (u64) to content_name")?;
+ let cal_webhook_service = CalWebhookServiceImpl::new(
+ CalConfig {
+ webhook_secret: cal_webhook_secret.as_ref().to_string(),
+ event_type_content_names: cal_event_type_content_names,
+ },
+ AnalyticsClientSink::new(analytics_client.clone()),
+ );
+ let cal_webhook_state = CalWebhookRouterState::new(cal_webhook_service);
+
// Call service (LiveKit)
let transcription_agent_name =
config::LivekitTranscriptionAgentName::new().map(|v| v.as_ref().to_owned());
@@ -477,6 +515,7 @@ async fn main() -> anyhow::Result<()> {
call_state,
call_webhook_state,
call_internal_state,
+ cal_webhook_state,
entity_access_management_service,
};