/
[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 :

    • 1data class WhatsappConfigModel( 2 @SerialName("country") val country: String?, 3 @SerialName("country_code") val code: String?, 4 @SerialName("msgTxt") val template: String?, 5)
  • 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

    • 1// previous reqquest had following query params : 2"reference_number" , 3"action" 4 5// CURRENT DEV WILL HAVE : 6"reference_number", 7"action", 8"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

    • 1// Previous response for fetching whatsapp configs using fetchAndValidate 2 3@Serializable 4data class FetchAndValidateResponseModel( 5 @SerialName("status") val status: String?, 6 @SerialName("data") val data: FetchAndValidateResponseModelData? 7 8) 9 10@Serializable 11data class FetchAndValidateResponseModelData( 12 @SerialName("destination_whatsapp_config") val destination_whatsapp_config: WhatsappConfigModel?, 13 @SerialName("origin_whatsapp_config") val origin_whatsapp_config: WhatsappConfigModel? 14)
    • 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 :

    • 1@Serializable 2data class FetchAndValidateResponseModel( 3 @SerialName("status") val status: String?, 4 @SerialName("whatsapp_config") val whatsapp_config: WhatsappConfigModel? 5)
    • Now Whatsapp Config changes to handle multiple templates :

    • 1// EXISTING MODEL 2@Serializable 3data class WhatsappConfigModel( 4 @SerialName("country") val country: String?, 5 @SerialName("country_code") val code: String?, 6 @SerialName("msgTxt") val template: String?, 7)
    • Changes to be done and expected in this task :

    • 1@Serializable 2data class WhatsappConfigModel( 3 @SerialName("country") val country: String?, 4 @SerialName("country_code") val code: String?, 5 @SerialName("templates") val templates :List<Template> 6) 7 8data class Template( 9 @SerialName("summary") val country: String?, 10 @SerialName("message") val code: String?, 11)
    • 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 .