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

Set action-specific "date added to group X" field on RapidPro contacts #902

Closed
wants to merge 9 commits into from

Conversation

toolness
Copy link
Collaborator

@toolness toolness commented Oct 25, 2019

Note: this PR isn't intended for merging, I'm going to just run it locally and then close this PR to ensure that the code is recorded somewhere.

Currently our RapidPro campaigns trigger off the "Created On" contact field, which is fine when a user signs up with us and immediately pursues an action. However, if the user waits before completing an action, or if they pursue multiple actions, the campaign events may never trigger.

We're going to be migrating to a model where we have custom user fields that represent the date/time when a user was added to a certain group, and have our campaigns trigger off those instead. This does the data migration of making sure our current users still receive follow-ups once the switch-over occurs.

For more details see our private clubhouse ticket.

@toolness
Copy link
Collaborator Author

Note that we also don't have to actually run this script; on October 23, I modified our RapidPro flows so that we set the correct custom date field (e.g. date_of_loc_sent_letter) when needed, and the longest campaign is 4 weeks. That means that in about 3 weeks, all users in our campaigns will already have their custom date field(s) set appropriately, so we can just stop using "created on" as a trigger at that time, without fear of throwing anyone off their campaign (I think).

@toolness toolness changed the title Migrate 'created_on' field of RapidPro accounts to action-specific field Set action-specific "date added to group X" field on RapidPro contacts Nov 5, 2019
@toolness
Copy link
Collaborator Author

toolness commented Nov 5, 2019

Ok, I've changed things so that instead of just setting the custom date fields to the "created on" date field, we actually go through each user's history and figure out when they completed the flow that added the user to the relevant contact group. This means the date will be accurate and we can easily figure out what users were never reached because their "created on" date was so out-of-sync with the date they were added to a group.

@toolness
Copy link
Collaborator Author

toolness commented Nov 6, 2019

Ok, I've run this code and all our fields are migrated over, so I'm closing this PR.

@toolness toolness closed this Nov 6, 2019
@toolness toolness deleted the migrate-rapidpro-dates branch November 6, 2019 22:23
@toolness toolness added the code snippet Temporary code that we only need to run once and don't need to merge for long-term use. label Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code snippet Temporary code that we only need to run once and don't need to merge for long-term use.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant