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 audience = p.dripAudience === 'all_inbound' ? 'all_inbound' : 'matched';
|
||||||
|
const welcomeCtas = normalizeWhatsAppCtas(p.welcomeCtas, { strict: true });
|
||||||
return {
|
return {
|
||||||
enabled: Boolean(p.enabled),
|
enabled: Boolean(p.enabled),
|
||||||
allowNonRegistered: Boolean(p.allowNonRegistered),
|
allowNonRegistered: Boolean(p.allowNonRegistered),
|
||||||
prefillText: String(p.prefillText != null ? p.prefillText : 'Hi').trim() || 'Hi',
|
prefillText: String(p.prefillText != null ? p.prefillText : 'Hi').trim() || 'Hi',
|
||||||
welcomeMessage: String(p.welcomeMessage != null ? p.welcomeMessage : ''),
|
welcomeMessage: String(p.welcomeMessage != null ? p.welcomeMessage : ''),
|
||||||
|
welcomeCtas,
|
||||||
unmatchedBadgePrompt: String(p.unmatchedBadgePrompt != null ? p.unmatchedBadgePrompt : ''),
|
unmatchedBadgePrompt: String(p.unmatchedBadgePrompt != null ? p.unmatchedBadgePrompt : ''),
|
||||||
staffHandoffMessage: String(p.staffHandoffMessage != null ? p.staffHandoffMessage : ''),
|
staffHandoffMessage: String(p.staffHandoffMessage != null ? p.staffHandoffMessage : ''),
|
||||||
dripAudience: audience,
|
dripAudience: audience,
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,14 @@ const conciergeBotSchema = new mongoose.Schema(
|
||||||
type: String,
|
type: String,
|
||||||
default: 'Hi {firstName}! Welcome to {eventName}.',
|
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: {
|
unmatchedBadgePrompt: {
|
||||||
type: String,
|
type: String,
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ const receptionSchema = Joi.object({
|
||||||
allowNonRegistered: Joi.boolean(),
|
allowNonRegistered: Joi.boolean(),
|
||||||
prefillText: Joi.string().allow(''),
|
prefillText: Joi.string().allow(''),
|
||||||
welcomeMessage: Joi.string().allow(''),
|
welcomeMessage: Joi.string().allow(''),
|
||||||
|
welcomeCtas: Joi.array().items(ctaItemSchema).max(3),
|
||||||
unmatchedBadgePrompt: Joi.string().allow(''),
|
unmatchedBadgePrompt: Joi.string().allow(''),
|
||||||
staffHandoffMessage: Joi.string().allow(''),
|
staffHandoffMessage: Joi.string().allow(''),
|
||||||
dripAudience: Joi.string().valid('matched', 'all_inbound'),
|
dripAudience: Joi.string().valid('matched', 'all_inbound'),
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* @returns {{ type: 'reply'|'url', label: string, value: string }[]}
|
* @returns {{ type: 'reply'|'url', label: string, value: string }[]}
|
||||||
*/
|
*/
|
||||||
function isPlaceholderCtaUrl(value) {
|
function isPlaceholderCtaUrl(value) {
|
||||||
return /\{engagementUrl\}|\{eventId\}|\{participantId\}/i.test(String(value || ''));
|
return /\{url\}|\{engagementUrl\}|\{eventId\}|\{participantId\}/i.test(String(value || ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
function isHttpCtaUrl(value) {
|
function isHttpCtaUrl(value) {
|
||||||
|
|
@ -33,7 +33,7 @@ function normalizeWhatsAppCtas(raw, opts = {}) {
|
||||||
if (type === 'url') {
|
if (type === 'url') {
|
||||||
if (!isHttpCtaUrl(value) && !isPlaceholderCtaUrl(value)) {
|
if (!isHttpCtaUrl(value) && !isPlaceholderCtaUrl(value)) {
|
||||||
if (strict) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue