使用 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