/
[TECHDOC][MOBILE] NDR Based OTP


Jira Ticket :

https://app.devrev.ai/shipsy/works/ISS-255559


Problem Statement :

OTP to be triggered based on selected undelivered reason . This is to be handled in App flow V2 config

Solution :

1. In App flow v2 ,

  • we receive App flow config , where on undelivered , the config with flow id : failure_config is used in transaction where we use step single_choice_reason .

  • This step has list of reason and branch step based on reason id .

  • Now each NDR will be mapped with list of steps ,

    • For NDR , with step OTP , if this feature is enabled , app will expect key : should_generate_otp

    • similar to shown in json below :

    • 1"branch_steps": { 2 "NSR": [ 3 { 4 "action_id": "otp", 5 "type": "otp_dialog", 6 "control": { 7 "visibility": "mandatory" 8 }, 9 "config": { 10 "should_generate_otp": true 11 }, 12 "ui": { 13 "pretty_name": "OTP" 14 } 15 } 16 ], 17 "INCORRECT ADDRESS": [ 18 { 19 "action_id": "otp", 20 "type": "otp_dialog", 21 "control": { 22 "visibility": "optional" 23 }, 24 "config": { 25 "should_generate_otp": false 26 }, 27 "ui": { 28 "pretty_name": "OTP" 29 } 30 } 31 ] 32},
    • In Above example ,

      • We will show a button to generate OTP in the OTP screen

2. UI / UX Actions

Send OTP

  • as mentioned above , button : Send OTP will be shown on UI based on above explained configs

  • On clicking Send OTP , it will call api : /api/RiderApp/validateOtpOnDelivery

  • request body will now contain : status where status will be attempted signifying undelivered flow .

  • This will trigger message to end customer.

  • Request Body now will look like :

  • 1@Serializable 2data class ResendDeliveryOtpRequest( 3 @SerialName("reference_number") 4 val referenceNumber: String, 5 @SerialName("task_id") 6 val taskId: String, 7 @SerialName("status") 8 val status: String 9)
  • On Response , we will handle success or failure , to intimate user about API status i.e., success or failure via Toast message.

  • use-case modified will be ResentOtpUseCase

ResendOtp

  • Same Request will go for every Resend / Send OTP click , no check based on should_generate_otp received in app flow v2 config.


Verify OTP

  • here if otp was generated , /api/RiderApp/validateOtpOnDelivery API will be called

  • Request JSON will look like :

  • 1{ 2"status": "attempted", 3"task_id": "TASK789", 4"task_failure_reason_id": "REASON001", 5"otp": "123456" // entered by user 6} 7
  • Currently , there is no API called in app flow v2 for validating , it is matched with task.otp

  • So this flow will be executed when should_generate_otp is true.

  • UseCase modified : OtpUseCase

Rest flow will be same as existing.