Table of Contents
Open questions
Business Questions
Is there a business rule that demands that only verified phone numbers can be used in customer search?
Business Answers
Tech Questions
Why do two different Interfaces for lookupByPhone records exist? (one in
user-service
and another inintl-packages
)Does accessing user-service phone lookup records from intl-packages violate the current architecture?
Since Admin App is not using Launch Darkly, does it have a strategy defined for Feature Toggles?
Tech Answers
This is legacy from US, and neither of them are used today, since sign up via phone is disabled in international.
Yes, we should create a new endpoint in user-service to search by phone number.
Business problem
This feature aims to implement the option to search for customers by phone in RBI Admin tool. This was a business request from Iberia ( - IREQ-961Getting issue details... STATUS ), given that customer support doesn’t always have the user’s email when trying to find them.
Tech Discovery
Architecture AS-IS
Today, Admin Tool only has the option to search customers by email or Cognito ID. The search by email is exemplified by the following sequence diagram.
The most direct solution is using intl-packages
, which already exposes a method to search users by phone number and DynamoDB queries for userLookupByPhone
records associating phone numbers to Cognito IDs. However, there is a divergence between the records created using intl-packages
and the ones created by user-service
, as can be seen below:
intl-packages:
{ pk: phoneNumber, pk2: cognitoId, sk: current/user-lookup-by-phone sk2: current/user-lookup-by-phone/{date} }
user-service:
{ pk: phone#${phoneNumber}, pk2: phone_user#${cognitoId}, sk: v0_UserPhone, sk2: v0_UserPhoneUserPhoneLookUp, }
The user-service
record is created when a user verifies their phone number via SMS. As far as we can tell, no one is using intl-packages
lookup records since its only reference is its own test.
This poses a problem, given that Iberia doesn’t require the customer to verify its phone, since they can use email.
Proposed solution
Add the option in intl-packages
to search users by phone number, and change user-service API to create/update lookupByPhoneNumber
records whenever there are changes in the customer's phone number.
It’s important to notice that since lookupByPhoneNumber
records haven’t been created for existing users, a script will have to be developed to scan all users in DynamoDB and create their associated lookup records.
Necessary changes - summary
User Service API: Adapt GET user endpoint to also search by phone number
User Service API: Adapt the
create
method in user service to create alookupByPhoneNumber
record if a phone number is informedUser Service API: Adapt
update-user
lambda to update or create alookupByPhoneNumber
record if the phone number changedUser Service API: Add a
isPhoneNumberVerified
field tolookupByPhoneNumber
interface. This is important to avoid impacting https://rbictg.atlassian.net/wiki/spaces/EGMT/pages/4329078785/Solution+Phone+Number+Authentication+for+BK+SA#Customer-support-toolUser packages: Change
getByPhoneNumber
to use User Service API instead of directly accessing the databaseAdmin App Backend: Create a GraphQL query to request customers by phone number
Admin App Frontend: Add the option to search customers by phone using the new query
DynamoDB: Develop a migration script to create
lookupByPhoneNumber
for existing customers
Diagrams
Search customer by phone sequence diagram:
Necessary changes - details
intl-user-service
Include the
isVerified
field inIUserLookupByPhone
Interface: https://github.com/rbilabs/intl-user-service/blob/master/src/users/user-lookup-by-phone.repository.ts#L25-L30
export interface IUserLookupByPhone { pk: string; pk2: string; sk: string; sk2: string; isVerified: boolean; }
Create
lookupByPhoneNumber
record after creating the user in dynamo inside thepre-signup
lambda, but only if a phone number is informed: https://github.com/rbilabs/intl-user-service/blob/master/src/cognito-lambdas/pre-signup.service.ts#L135Update the
lookupByPhoneNumber
record if an user update is triggered and includes the phone number: https://github.com/rbilabs/intl-user-service/blob/master/src/users/update-comm-pref.service.ts#L150Adapt the get user endpoint to have an
phoneNumber
query field, that searches by phone: https://github.com/rbilabs/intl-user-service/blob/master/src/users/users.controller.ts#L124
intl-packages
Create the option to search
lookupByPhone
records created byuser-service
using the endpoint. Currently,getByEmail
already works this way (https://github.com/rbilabs/intl-packages/blob/master/packages/users/src/users.ts#L359).
This changes are already implemented in this git branch: https://github.com/rbilabs/intl-packages/pull/961
intl-admin-app
Create a GraphQL query that uses the
searchByPhone
method exposed by intl-packagesUpdate the UI to display the search by phone number option
These main changes are implemented in this git branch: https://github.com/rbilabs/intl-admin-app/pull/242
However, Admin App currently doesn’t use Launch Darkly, which makes it harder to control the feature activation for different markets and makes it riskier. Possible alternatives are:
Pros | Cons | |
---|---|---|
Add and configure Launch Darkly in Admin App |
|
|
Implement FT using environment variables |
|
|
Only display the search by phone option in Iberia market |
|
|
Add Comment