← back to Dw Chat Analyzer
Chat analyzer: /api/new-hot endpoint for FileMaker to pull (Insert from URL) + real Zendesk agent-workspace link (designerwallcoverings.zendesk.com)
47a430ffeb5c599585ee3d2209e6ea904047277a · 2026-08-11 08:26:19 -0700 · steve
Files touched
Diff
commit 47a430ffeb5c599585ee3d2209e6ea904047277a
Author: steve <steve@designerwallcoverings.com>
Date: Tue Aug 11 08:26:19 2026 -0700
Chat analyzer: /api/new-hot endpoint for FileMaker to pull (Insert from URL) + real Zendesk agent-workspace link (designerwallcoverings.zendesk.com)
---
pull.py | 2 +-
server.js | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/pull.py b/pull.py
index 204e593..ab923c0 100644
--- a/pull.py
+++ b/pull.py
@@ -25,7 +25,7 @@ HERE = os.path.dirname(os.path.abspath(__file__))
CURSOR = os.path.join(HERE, ".cursor")
TABLE = "dw_chats"
# Standalone Zopim Chat account (no Support subdomain) → link back to the Chat dashboard.
-ZENDESK_LINK_BASE = os.environ.get("ZENDESK_LINK_BASE", "https://dashboard.zopim.com/#chats/agent/history")
+ZENDESK_LINK_BASE = os.environ.get("ZENDESK_LINK_BASE", "https://designerwallcoverings.zendesk.com/chat/agent#home")
LEAD_KW = re.compile(r"\b(quote|price|pricing|cost|buy|purchase|order|sample|swatch|"
r"yard|roll|availab|lead time|trade|designer|install|ship)\b", re.I)
diff --git a/server.js b/server.js
index bb9d981..15f7794 100644
--- a/server.js
+++ b/server.js
@@ -73,6 +73,17 @@ const server=http.createServer(async(req,res)=>{
if(url.pathname==='/'||url.pathname==='/index.html')return send(res,200,fs.readFileSync(path.join(__dirname,'public','index.html')),'text/html; charset=utf-8');
if(url.pathname==='/api/stats')return send(res,200,await apiStats());
if(url.pathname==='/api/chats')return send(res,200,await apiChats(url.searchParams));
+ // FileMaker pulls this (Insert from URL) to pop an on-screen dialog for new HOT chats.
+ if(url.pathname==='/api/new-hot'){
+ const since=url.searchParams.get('since')||new Date(Date.now()-864e5).toISOString();
+ const r=await pool.query(
+ `SELECT id, started_at, coalesce(nullif(visitor_email,''),nullif(visitor_phone,''),'(contact on file)') contact,
+ nullif(concat_ws(', ',nullif(visitor_city,''),nullif(visitor_region,''),nullif(visitor_country,'')),'') location,
+ regexp_replace(landing_page,'^https?://[^/]+','') landing, zendesk_link
+ FROM ${T} WHERE lead_tier='HOT' AND started_at > $1::timestamptz
+ ORDER BY started_at DESC LIMIT 25`,[since]);
+ return send(res,200,{count:r.rows.length, latest:r.rows[0]?r.rows[0].started_at:since, chats:r.rows});
+ }
if(url.pathname==='/healthz')return send(res,200,{ok:true});
return send(res,404,{error:'not found'});
}catch(e){console.error(e);return send(res,500,{error:String(e.message||e)});}
← ef41f56 Chat analyzer: new-HOT-lead watcher (watch.js) — polls newes
·
back to Dw Chat Analyzer
·
Add FileMaker on-screen alert recipe (Insert-from-URL pull + e92a327 →