diff --git a/channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/dto/JaicpNativeBotRequest.kt b/channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/dto/JaicpNativeBotRequest.kt index 192aa138..0cd233ee 100644 --- a/channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/dto/JaicpNativeBotRequest.kt +++ b/channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/dto/JaicpNativeBotRequest.kt @@ -64,6 +64,14 @@ interface TelephonyBotRequest : JaicpNativeBotRequest { ?.jsonObject?.get("schedule")?.jsonObject?.get("dialSchedule")?.jsonObject ?.let(JSON::decodeFromJsonElement) + /** + * Returns an object with data about the transfer status of a customer to an operator. + * + * @see [TransferStatus] + */ + val transferStatus: TransferStatus? + get() = jaicp.rawRequest.jsonObject["transferStatus"]?.let(JSON::decodeFromJsonElement) + /** * Returns a token for downloading call recordings made in the current project. * The Record calls toggle in the phone channel settings must be set to active so that call recordings become available for download. @@ -111,6 +119,26 @@ interface TelephonyBotRequest : JaicpNativeBotRequest { } } +/** + * Contains the status of the transfer of a customer to an operator. + * + * @property status agent transfer status. It returns a string: `SUCCESS` or `FAIL`. + * + * @property hangup true means the customer has ended the conversation. + * false means the customer is still online and was re-directed to the bot (if continueCall: true in [TelephonySwitchReply]). + * + * @property number the phone number the call was transferred to. + */ + +@Serializable +data class TransferStatus( + val status: String, + val hangup: Boolean, + val number: String +) { + val isSuccess = status == "SUCCESS" +} + @Serializable data class Schedule( val allowedDays: List? = null,