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

21677: Mailchimp SMS - Integration Update #249

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

VSydor
Copy link
Contributor

@VSydor VSydor commented Oct 29, 2024

@VSydor VSydor requested a review from brmeyer October 29, 2024 21:49
@VSydor VSydor self-assigned this Oct 29, 2024
} catch (MailchimpException e) {
env.logJobWarn("Mailchimp syncContacts failed: {}", mailchimpClient.exceptionToString(e));
} catch (Exception e) {
env.logJobWarn("Mailchimp syncContacts failed", e);
}
}

protected void backfillContacts(List<CrmContact> contacts, List<MemberInfo> memberInfos) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

@VSydor We can remove this method and no need to call it from syncContacts. For the backfill, let's take the code you put together in dr-hub (the implementation of this method) and we'll instead do a one-time script in ManualUtil. The backfill is just a one-time thing to catch MC contacts up. After that, it's just the normal daily sync as contacts update in SFDC.

@@ -421,6 +424,12 @@ protected MemberInfo toMcMemberInfo(CrmContact crmContact, Map<String, Object> c
mcContact.merge_fields.mapping.put(FIRST_NAME, crmContact.firstName);
mcContact.merge_fields.mapping.put(LAST_NAME, crmContact.lastName);
mcContact.merge_fields.mapping.put(PHONE_NUMBER, crmContact.mobilePhone);

mcContact.consents_to_one_to_one_messaging = true; //?
Copy link
Contributor

Choose a reason for hiding this comment

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

@VSydor Do the docs mention what this field is, how it differs from sms_subscription_status, and if this is required? No concerns, just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm afraid the filed has a very brief description in the API docs (and is only listed in response examples):
consents_to_one_to_one_messaging
boolean
Indicates whether a contact consents to 1:1 messaging.
(https://mailchimp.com/developer/marketing/api/list-members/add-member-to-list/)

import static com.impactupgrade.nucleus.client.MailchimpClient.LAST_NAME;
import static com.impactupgrade.nucleus.client.MailchimpClient.PHONE_NUMBER;
import static com.impactupgrade.nucleus.client.MailchimpClient.SUBSCRIBED;
import static com.impactupgrade.nucleus.client.MailchimpClient.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Picky: kill wildcard imports in your IDE?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Snap - must have defaulted my settings for this after re-installing/updating IDE
will remove wildcards


if (!Strings.isNullOrEmpty(crmFields.smsOptIn) && !crmFields.listFilterOverridesOptIn) {
clauses.add(crmFields.smsOptIn + "=TRUE");
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@VSydor I think we should probably remove this block for now. IIUC, DR wants SMS to be additive to contacts that are already in MC due to an email subscription, and no contacts in MC purely for SMS (and no email). And if you look at the uses of the CrmContact.canReceiveEmail() method, you'll see we're using it to decide multiple pieces of the sync, including who to archive. Maybe in the future they'll want us to sync SMS-only contacts. But for now, kill this block and we'll still sync only contacts that are email-ready? And if they happen to also be SMS opted in, that gets set too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right
I was overthinking this (thought should be very separate filter)

@@ -421,6 +424,12 @@ protected MemberInfo toMcMemberInfo(CrmContact crmContact, Map<String, Object> c
mcContact.merge_fields.mapping.put(FIRST_NAME, crmContact.firstName);
mcContact.merge_fields.mapping.put(LAST_NAME, crmContact.lastName);
mcContact.merge_fields.mapping.put(PHONE_NUMBER, crmContact.mobilePhone);

mcContact.consents_to_one_to_one_messaging = true; //?
mcContact.sms_phone_number = crmContact.mobilePhone;
Copy link
Contributor

Choose a reason for hiding this comment

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

@VSydor Update this to use crmContact.phoneNumberForSMS() instead -- it attempts Home Phone if Mobile doesn't exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But is it possible to send sms to a home phone?

mcContact.consents_to_one_to_one_messaging = true; //?
mcContact.sms_phone_number = crmContact.mobilePhone;
mcContact.merge_fields.mapping.put(SMS_PHONE_NUMBER, crmContact.mobilePhone);
mcContact.sms_subscription_status = SUBSCRIBED;
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't set this (and shouldn't set the phone number or consents either) unless CrmContact has smsOptIn=true and smsOptOut=false

Copy link
Contributor

@brmeyer brmeyer Nov 12, 2024

Choose a reason for hiding this comment

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

Also, as mentioned in Slack, add a countryCode configuration in env.json's Mailchimp account section. If the contact's number starts with that countryCode, OR if the contact's number does NOT start with a country code at all, only then allow it to be opted it into SMS here -- it appears MC only allows numbers from the country the account's organization is within.

@VSydor VSydor force-pushed the feature/21677-mailchimp-sms-integration-update branch from fd87910 to ca08cf2 Compare November 12, 2024 23:08
@VSydor VSydor requested a review from brmeyer November 12, 2024 23:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants