Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Enable twilio whatsapp template #1391

Merged
merged 14 commits into from
Sep 6, 2023
15 changes: 15 additions & 0 deletions apps/meteor/app/livechat/server/sendMessageBySMS.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ callbacks.add(
extraData = Object.assign({}, extraData, { location });
}

if (message.customFields && message.customFields.contentSid) {
const { contentSid } = message.customFields;
extraData = Object.assign({}, extraData, { contentSid });
}

if (message.customFields && message.customFields.contentVariables) {
const { contentVariables } = message.customFields;
extraData = Object.assign({}, extraData, { contentVariables });
}

if (message.customFields && message.customFields.messagingServiceSid) {
const { messagingServiceSid } = message.customFields;
extraData = Object.assign({}, extraData, { messagingServiceSid });
}

const SMSService = SMS.getService(settings.get('SMS_Service'));

if (!SMSService) {
Expand Down
15 changes: 15 additions & 0 deletions apps/meteor/app/sms/server/services/twilio.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ class Twilio {
body = TAPi18n.__('Location', { lng: defaultLanguage });
}

let contentSid;
let contentVariables;
let messagingServiceSid;
if (extraData && extraData.contentSid) {
contentSid = extraData.contentSid;
messagingServiceSid = extraData.messagingServiceSid;
}

if (extraData && extraData.contentVariables) {
contentVariables = JSON.stringify(extraData.contentVariables);
}

if (!messageQueue[toNumber]) {
messageQueue[toNumber] = [];
}
Expand All @@ -167,6 +179,9 @@ class Twilio {
body,
...(mediaUrl && { mediaUrl }),
...(persistentAction && { persistentAction }),
...(contentSid && { contentSid }),
ear-dev marked this conversation as resolved.
Show resolved Hide resolved
...(messagingServiceSid && { messagingServiceSid }),
...(contentVariables && { contentVariables }),
});

if (!messageQueueProcessor[toNumber]) {
Expand Down