/
[TECHDOC][MOBILE] Whatsapp Templates for Rider

[TECHDOC][MOBILE] Whatsapp Templates for Rider

 

Ticket :

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

Problem Statement :

To provide template options for rider to initiate conversation with end customer.

https://shipsy.atlassian.net/browse/CORE-218723

Solution :

Existing Flow :

  • Currently, Whatsapp button is provided on Pending Task Screen i.e. CurrentTaskListScreen class in App flow V2 .

  • To check if this feature is enabled , we get config : whatsapp_config.show , if this is true , we show the Whatsapp icon button.

    • This is very well handled in usecase IsWhatsAppEnabledUseCase

  • Now on Whatsapp button click , we make a call to API : fetchAndValidate

    • This gives us details of message template rider will send to end customer.

    • Model Class looks like this :

    • data class WhatsappConfigModel( @SerialName("country") val country: String?, @SerialName("country_code") val code: String?, @SerialName("msgTxt") val template: String?, )
  • Now , on receiving country code and message template , we validate the customer number using the provided customer code.

  • And then process message data and send final result to UI to open whatsapp.

Changes Required in Current Development :

  • FetchAndValidate API :

    • Request

    • // previous reqquest had following query params : "reference_number" , "action" // CURRENT DEV WILL HAVE : "reference_number", "action", "task_id"
    • The Task ID added in fetch and validate request will provide us with only one type of whatsapp config model instead of 2 types i.e., origin and delivery

    • Response Model of Previous Response

    • // Previous response for fetching whatsapp configs using fetchAndValidate @Serializable data class FetchAndValidateResponseModel( @SerialName("status") val status: String?, @SerialName("data") val data: FetchAndValidateResponseModelData? ) @Serializable data class FetchAndValidateResponseModelData( @SerialName("destination_whatsapp_config") val destination_whatsapp_config: WhatsappConfigModel?, @SerialName("origin_whatsapp_config") val origin_whatsapp_config: WhatsappConfigModel? )
    • Previous response used to send 2 whatsapp config objects destination_whatsapp_config and origin_whatsapp_config but now since request has Task ID , on basis of that , we will be expecting only one object .

    • Expected Response Now :

    • Now Whatsapp Config changes to handle multiple templates :

    • Changes to be done and expected in this task :

    • Here , previously we received single templates which was processed to replace with rider and order data.

    • Now , we will expect the message to be processed in BE and complete message to be shown here.

 

  • UseCase Changes :

    • Changes in getWhatsappTemplateUseCase:

      • This will now return list of templates with summary which will be used as heading and messages which will already be processed .

      • This will be used to show a dialog / popup of list of messages in UI

      • on clicking a summary , message mapped to it will be send to the end customer as occuring in existing flow .

Add label