Update WhatsApp Concierge bot

This commit is contained in:
Tanuja Pansare 2026-10-19 12:43:02 +05:30
parent 237a754eb8
commit 1b212afb87
4 changed files with 14 additions and 3 deletions

View File

@ -65,11 +65,13 @@ function normalizeReceptionPayload(p) {
})
: [];
const audience = p.dripAudience === 'all_inbound' ? 'all_inbound' : 'matched';
const welcomeCtas = normalizeWhatsAppCtas(p.welcomeCtas, { strict: true });
return {
enabled: Boolean(p.enabled),
allowNonRegistered: Boolean(p.allowNonRegistered),
prefillText: String(p.prefillText != null ? p.prefillText : 'Hi').trim() || 'Hi',
welcomeMessage: String(p.welcomeMessage != null ? p.welcomeMessage : ''),
welcomeCtas,
unmatchedBadgePrompt: String(p.unmatchedBadgePrompt != null ? p.unmatchedBadgePrompt : ''),
staffHandoffMessage: String(p.staffHandoffMessage != null ? p.staffHandoffMessage : ''),
dripAudience: audience,

View File

@ -110,6 +110,14 @@ const conciergeBotSchema = new mongoose.Schema(
type: String,
default: 'Hi {firstName}! Welcome to {eventName}.',
},
/** Up to 3 reply CTAs or one URL CTA, sent with the welcome inside the session window. */
welcomeCtas: [
{
type: { type: String, enum: ['reply', 'url'], required: true },
label: { type: String, default: '', trim: true, maxlength: 20 },
value: { type: String, default: '', trim: true, maxlength: 2000 },
},
],
unmatchedBadgePrompt: {
type: String,
default:

View File

@ -106,6 +106,7 @@ const receptionSchema = Joi.object({
allowNonRegistered: Joi.boolean(),
prefillText: Joi.string().allow(''),
welcomeMessage: Joi.string().allow(''),
welcomeCtas: Joi.array().items(ctaItemSchema).max(3),
unmatchedBadgePrompt: Joi.string().allow(''),
staffHandoffMessage: Joi.string().allow(''),
dripAudience: Joi.string().valid('matched', 'all_inbound'),

View File

@ -7,7 +7,7 @@
* @returns {{ type: 'reply'|'url', label: string, value: string }[]}
*/
function isPlaceholderCtaUrl(value) {
return /\{engagementUrl\}|\{eventId\}|\{participantId\}/i.test(String(value || ''));
return /\{url\}|\{engagementUrl\}|\{eventId\}|\{participantId\}/i.test(String(value || ''));
}
function isHttpCtaUrl(value) {
@ -33,7 +33,7 @@ function normalizeWhatsAppCtas(raw, opts = {}) {
if (type === 'url') {
if (!isHttpCtaUrl(value) && !isPlaceholderCtaUrl(value)) {
if (strict) {
throw new Error('URL buttons must start with http:// or https://, or use {engagementUrl}');
throw new Error('URL buttons must start with http:// or https://, or use {Url}');
}
continue;
}