Skip to content

Commit b816ad1

Browse files
committed
fix create templates script
1 parent 71f858d commit b816ad1

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/scripts/createTwilioRes.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ import {
55
createWhatsAppTemplate,
66
} from "@/lib/twilio";
77
import nextConfig from "../../next.config";
8-
import { getEventRegistrationTemplate, getHelpPrivacyTemplate, getOrderCancelledTemplate, getOrderConfirmationTemplate, getOrderReadyTemplate, getOrderReminderTemplate, getReadyToOrderLimitlessTemplate, getReadyToOrderLimitlessWithoutEmailValidationTemplate, getReadyToOrderTemplate, getReadyToOrderWithoutEmailValidationTemplate, getWrongOrderTemplate, WhatsAppTemplate } from "./buildContentTemplates";
8+
import {
9+
getEventRegistrationTemplate,
10+
getHelpPrivacyTemplate,
11+
getOrderCancelledTemplate,
12+
getOrderConfirmationTemplate,
13+
getOrderReadyTemplate,
14+
getOrderReminderTemplate,
15+
getReadyToOrderLimitlessTemplate,
16+
getReadyToOrderLimitlessWithoutEmailValidationTemplate,
17+
getReadyToOrderTemplate,
18+
getReadyToOrderWithoutEmailValidationTemplate,
19+
getWrongOrderTemplate,
20+
WhatsAppTemplate,
21+
} from "./buildContentTemplates";
922

1023
// this script runs mostly sequentially. Use a throttled queue later to optimize if needed
1124

@@ -46,12 +59,12 @@ async function createWhatsAppTemplates() {
4659
);
4760

4861
if (Boolean(OVERRIDE_TEMPLATES)) {
49-
try {
50-
for await (const t of templates) {
62+
for await (const t of templates) {
63+
try {
5164
await deleteWhatsAppTemplate(t.sid); // Sequentially delete all templates to avoid rate limiting
65+
} catch (e: any) {
66+
console.error("Error deleting WhatsApp Templates ", e.message);
5267
}
53-
} catch (e: any) {
54-
console.error("Error deleting WhatsApp Templates ", e.message);
5568
}
5669
console.log(`Deleted ${templates.length} templates.`);
5770
templates = (await getAllWhatsAppTemplates()).filter((t) =>

0 commit comments

Comments
 (0)