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

Webhook & schema changes to monitor user group switching #70

Closed
2 tasks done
Satendra-SR opened this issue Mar 31, 2021 · 7 comments
Closed
2 tasks done

Webhook & schema changes to monitor user group switching #70

Satendra-SR opened this issue Mar 31, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request priority: high This issue or pull request is on high priority status: ready to test type: research This issue is for research purpose

Comments

@Satendra-SR
Copy link
Member

Satendra-SR commented Mar 31, 2021

Is your feature request related to a problem? Please describe.
We are handling user groups switching at Rapidpro level. Whenever a flow runs for a user, it remove the user from that particular group and add it to a different group. There are a few chances where the user is not getting removed from a group/ getting added to other group, and user is either keep receiving the same call or multiple calls due to multiple group assignment.

We need to capture the use's group assignment.

Describe the solution you'd like
Capture the user's group assignment whenever a flow runs.

  • Come up with the plan and db schema changes
  • Implement the changes based on discussions.

Describe alternatives you've considered
None

Additional context
None

@Satendra-SR Satendra-SR added the enhancement New feature or request label Mar 31, 2021
@Satendra-SR Satendra-SR self-assigned this Mar 31, 2021
@Satendra-SR Satendra-SR added the priority: high This issue or pull request is on high priority label Mar 31, 2021
@Satendra-SR
Copy link
Member Author

Satendra-SR commented Apr 5, 2021

The proposed solution would be:

  1. Each time, a flow will run, we will pass the user's group info to the webhook
  2. At system level:
    1. Check if the user-group association is already captured in the Database.
    2. If not exists:
      1. Capture user-group association.
      2. Check the active association each time when handling webhook requests. If the association is still active, mark if ACTIVE. Else, mark if IN-ACTIVE.
      3. Check for the previous associations, if those are still active, keep them as ACTIVE. Else mark it IN-ACTIVE.

Required Database changes:

There are two possible ways to capture these data with the required change in the DB

Solution 1:

Having a single table called user_groups

Table structure:

column type options foreign key
id int
user_id int user -> id
registration_id int registration -> id
user_phone varchar
group_name varchar
status varchar active / in-active
created_on timestamp
updated_on timestamp

Solution 2:

Having two tables user_groups and group (or contact_groups). In this approach, we will need to pre-populate the groups table data.

Table structure:

  1. user_groups
column type options foreign key
id int
user_id int user -> id
registration_id int registration -> id
user_phone varchar
group_id int groups -> id
status varchar active / in-active
created_on timestamp
updated_on timestamp
  1. groups or contact_groups
column type options
id int
name int
status varchar active / in-active
created_on timestamp
updated_on timestamp

We can discussion more on adding user_phone in details, but in short, this it to ease out analytics.

@Satendra-SR Satendra-SR added the type: research This issue is for research purpose label Apr 5, 2021
@prtkdost
Copy link

prtkdost commented Apr 6, 2021

This looks good. I think first option is better but we can discuss before finalizing.

@Satendra-SR
Copy link
Member Author

We can fo with option 1

@Satendra-SR
Copy link
Member Author

This got close but Github automation, reopening for testing.

@Satendra-SR Satendra-SR reopened this Apr 20, 2021
@Satendra-SR
Copy link
Member Author

This is deployed on UAT and ready for testing.

Note: Please use these two flows for testing or create new for testing.

  1. DOST-Test-P2M7D4-devteam
  2. FINAL-DOST-test-OnboardingCall-devteam

Steps to test:

  1. Schedule a call from above flows.
  2. Check user_group table for latest entry for your phone number.
  3. Check the table is populated with correct user group information.

@Satendra-SR
Copy link
Member Author

This is working fine on staging and production as well.

@rudresh
Copy link
Member

rudresh commented Apr 24, 2021

Everything is working as expected on prod. Closing this out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority: high This issue or pull request is on high priority status: ready to test type: research This issue is for research purpose
Projects
None yet
Development

No branches or pull requests

3 participants