Update WhatsApp Concierge bot
This commit is contained in:
parent
237a754eb8
commit
1b212afb87
|
|
@ -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,
|
||||
|
|
@ -1244,4 +1246,4 @@ module.exports = {
|
|||
syncEventKnowledge,
|
||||
syncFoodKnowledge,
|
||||
syncPlacesKnowledge,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue