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] Extract message service SID from incoming message and save to room #1398

Merged
merged 2 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/meteor/app/livechat/imports/server/rest/sms.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ API.v1.addRoute('livechat/sms-incoming/:service', {
roomInfo: {
sms: {
from: sms.to,
messaging_service_sid: sms.messagingServiceSid,
},
source: {
type: OmnichannelSourceType.SMS,
Expand Down
5 changes: 2 additions & 3 deletions apps/meteor/app/livechat/server/sendMessageBySMS.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ callbacks.add(
extraData = Object.assign({}, extraData, { contentVariables });
}

if (message.customFields && message.customFields.messagingServiceSid) {
const { messagingServiceSid } = message.customFields;
extraData = Object.assign({}, extraData, { messagingServiceSid });
if (room.sms.messaging_service_sid) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this add messaging_service_sid to all of our bot responses to twilio, and not just the responses that include contentSid? Is that the way we want to do it? Are we sure that won't cause any confusion on the twilio side? Or should we just be adding this when there is also the customFields with contentSid?

extraData = Object.assign({}, extraData, { messagingServiceSid: room.sms.messaging_service_sid });
}

const SMSService = SMS.getService(settings.get('SMS_Service'));
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/app/sms/server/services/twilio.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Twilio {

parse(data) {
let numMedia = 0;
SystemLogger.debug('Incoming Twilio message: ', data);

const returnData = {
from: data.From,
Expand All @@ -74,6 +75,7 @@ class Twilio {
fromZip: data.FromZip,
fromLatitude: data.Latitude,
fromLongitude: data.Longitude,
messagingServiceSid: data.MessagingServiceSid,
},
};

Expand Down Expand Up @@ -178,7 +180,6 @@ class Twilio {

messageQueue[toNumber].push({
to: toNumber,
// from: contentSid ? messagingServiceSid : fromNumber,
from: fromNumber,
body,
...(mediaUrl && { mediaUrl }),
Expand Down
Loading