使用 Zapier 處理電話號碼格式
本指南向你展示如何將各種格式(例如 ClickFunnels 的格式)的電話號碼標準化為 ABC Sales AI 所要求的國際格式。
分步設定
1. 在 Zapier 中
新增一個新的 Action → Code by Zapier → Run Javascript。
2. 在 「Input Data」 中
新增一個名為 \phone\ 的欄位,並將其對應到你的 ClickFunnels 電話號碼輸出。
3. 貼上以下程式碼
\\\`javascript
// normalize
const raw = (inputData.phone || "").trim();
const digits = raw.replace(/\\D/g, "");
// if they already passed +60, 60, +65, 65, +673 or 673 → just ensure it has "+"
if (/^(\\+?60|60|(\\+?65)|65|(\\+?673)|673)/.test(digits)) {
// if they didn't include "+", add it
return {
formattedPhone: raw.startsWith("+")
? raw
: "+" + digits
};
}
// Malaysian mobiles all start "01…"
if (digits.startsWith("01")) {
return { formattedPhone: "+6" + digits };
}
// Singapore mobiles start "8…" or "9…" (8 digits long)
if (/^[89]/.test(digits)) {
return { formattedPhone: "+65" + digits };
}
// Brunei local numbers are 7 digits long
if (digits.length === 7) {
return { formattedPhone: "+673" + digits };
}
// Fallback-pass it through untouched
return { formattedPhone: raw };
\\\`
4. 在你的下一個 Webhook 步驟中
傳送 \formattedPhone\ 欄位,而非原始的電話號碼。
支援的格式
- 0123456789(MY 手機)→ +60123456789
- 60123456789 → +60123456789
- +60123456789 → +60123456789
- 81234567(SG 手機)→ +6581234567
- 91234567(SG 手機)→ +6591234567
- 1234567(7 位數,Brunei)→ +6731234567