WhatsApp flowchart

Key flowcharts for WhatsApp channel: basic, login and logout flows

WhatsApp basic flowchart

Flows for new messages from anonymous and authenticated users in the WhatsApp channel.

New WhatsApp message from anonymous user

@startuml
title: Basic flow for WhatsApp anonymous users
    actor User
    participant WhatsApp #f6b5ff
    participant KernelWhatsAppApi #99FFFF
    participant AuraBridge #1add4d
    participant AuraGroot #76bbe7
    participant AuthenticationApi #FFFF99
    participant AuraBot #41a0f9 
    participant TACApi #66B2FF
    participant AuraBridgeOutbound #1add4d

    User -> WhatsApp: Request [message]
    WhatsApp -> KernelWhatsAppApi: Request [message]
    KernelWhatsAppApi -> AuraBridge: Request [message]
    AuraBridge -> KernelWhatsAppApi: 200 OK
    AuraBridge -> AuraGroot: Request [message]
    Note over AuraBridge,AuraGroot: WhatsApp channels use channelData V2 between AuraBridge and AuraGroot
    AuraGroot -> AuraBridge: 200 OK
    AuraGroot -> AuraGroot: GetSkillByChannel
    AuraGroot -> AuraBot: Request [message]
    AuraBot -> AuraGroot: 200 OK
    AuraBot -> AuthenticationApi: GET auraId
    AuthenticationApi -> AuraBot: 404 Not Found (Anonymous user)
    Note left of TACApi: See Terms and Conditions flow
    AuraBot -> TACApi: Check terms and conditions
    TACApi -> AuraBot: 200 OK
    AuraBot -> AuraBot: Recognizers
    AuraBot -> AuraBot: Main Dialog
    AuraBot -> AuraBot: Execute Specific functional Dialog
    AuraBot -> AuraGroot: Response to [message]
    AuraGroot -> AuraBot: 200 OK
    AuraGroot -> AuraBridgeOutbound: Response to [message]
    AuraBridgeOutbound -> AuraGroot: 200 OK
    AuraBridgeOutbound -> KernelWhatsAppApi: Response to [message]
    KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
    KernelWhatsAppApi -> WhatsApp: Response to [message]
    WhatsApp -> User: Show response to [message]
@enduml

New WhatsApp message from authenticated user

@startuml
title: Basic flow for WhatsApp authenticated users
    actor User
    participant WhatsApp #f6b5ff
    participant KernelWhatsAppApi #99FFFF
    participant AuraBridge #1add4d
    participant AuraGroot #76bbe7
    participant AuthenticationApi #FFFF99
    participant AuraBot #41a0f9 
    participant TACApi #66B2FF
    participant KernelAuthServer #99FFFF
    participant KernelUserProfileApi #99FFFF
    participant AuraBridgeOutbound #1add4d

    User -> WhatsApp: Request [message]
    WhatsApp -> KernelWhatsAppApi: Request [message]
    KernelWhatsAppApi -> AuraBridge: Request [message]
    AuraBridge -> KernelWhatsAppApi: 200 OK
    AuraBridge -> AuraGroot: Request [message]
    Note over AuraBridge,AuraGroot: WhatsApp channels use channelData V2 between AuraBridge and AuraGroot
    AuraGroot -> AuraBridge: 200 OK
    AuraGroot -> AuraGroot: GetSkillByChannel
    AuraGroot -> AuraBot: Request [message]
    AuraBot -> AuraGroot: 200 OK
    AuraBot -> AuraBot: GET userCache(auraId)
    opt User is not in cache
        AuraBot -> AuthenticationApi: GET AuraId
        AuthenticationApi -> AuraBot: 200 OK {userData}
        AuraBot -> KernelAuthServer: POST /token
        Note over AuraBot,KernelAuthServer: Here, a 3legged accessToken is requested
        KernelAuthServer -> AuraBot: {token}
        AuraBot -> KernelAuthServer: getIntrospect(token)
        opt channel allows UserProfile
            AuraBot -> KernelUserProfileApi: getUserProfile(userId)
            KernelUserProfileApi -> AuraBot: UserProfile
        end
        AuraBot -> AuraBot: store user in cache: userData, userProfile, valid scopes and purposes
    end
    Note left of TACApi: See Terms and Conditions flow
    AuraBot -> TACApi: Check terms and conditions
    TACApi -> AuraBot: 200 OK
    AuraBot -> AuraBot: Recognizers
    AuraBot -> AuraBot: Main Dialog
    AuraBot -> AuraBot: Execute Specific functional Dialog
    AuraBot -> AuraGroot: Response to [message]
    AuraGroot -> AuraBot: 200 OK
    AuraGroot -> AuraBridgeOutbound: Response to [message]
    AuraBridgeOutbound -> AuraGroot: 200 OK
    AuraBridgeOutbound -> KernelWhatsAppApi: Response to [message]
    KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
    KernelWhatsAppApi -> WhatsApp: Response to [message]
    WhatsApp -> User: Show response to [message]
@enduml

Terms & Conditions flowchart

@startuml

title: Acceptance of terms and conditions flow
    actor User
    participant WhatsApp #f6b5ff
    participant KernelWhatsAppApi #99FFFF
    participant AuraBridge #1add4d
    participant AuraGroot #76bbe7
    participant AuthenticationApi #FFFF99
    participant AuraBot #41a0f9 
    participant TACApi #66B2FF
    participant KernelAuthServer #99FFFF
    participant KernelUserProfileApi #99FFFF
    participant AuraBridgeOutbound #1add4d

    User -> WhatsApp: Request [message]
    WhatsApp -> KernelWhatsAppApi: Request [message]
    KernelWhatsAppApi -> AuraBridge: Request [message]
    AuraBridge -> KernelWhatsAppApi: 200 OK
    AuraBridge -> AuraGroot: Request [message]
    AuraGroot -> AuraBridge: 200 OK
    AuraGroot -> AuraGroot: GetSkillByChannel
    AuraGroot -> AuraBot: Request [message]
    AuraBot -> AuraGroot: 200 OK
    AuraBot -> AuraBot: GET userCache(auraId)
    alt User already accepted authenticated T&C or Channel doesn't have terms and conditions config
        AuraBot -> TACApi: GET termsAndConDitions(auraId)
        TACApi -> AuraBot: 200 OK
        Note left of AuraBot: See WhatSApp basic flow
        AuraBot -> AuraBot: Recognizers
        AuraBot -> AuraBot: Main Dialog
        AuraBot -> AuraBot: Execute Specific functional Dialog
        AuraBot -> AuraGroot: Response to [message]
        AuraGroot -> AuraBot: 200 OK
        AuraGroot -> AuraBridgeOutbound: Response to [message]
        AuraBridgeOutbound -> AuraGroot: 200 OK
        AuraBridgeOutbound -> KernelWhatsAppApi: Response to [message]
        KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
        KernelWhatsAppApi -> WhatsApp: Response to [message]
        WhatsApp -> User: Show response to [message]
    else User needs to accept authenticated T&C
        AuraBot -> TACApi: GET termsAndConditions(auraId)
        TACApi -> AuraBot: 404 Not found
        AuraBot -> AuraBot: executes terms and conditions dialog
        AuraBot -> AuraGroot: Send [onboarding messages]
        AuraGroot -> AuraBot: 200 OK
        AuraGroot -> AuraBridgeOutbound: Send [onboarding messages]
        AuraBridgeOutbound -> AuraGroot: 200 OK
        AuraBridgeOutbound -> KernelWhatsAppApi: Send [onboarding messages]
        KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
        KernelWhatsAppApi -> WhatsApp: Send [onboarding messages]
        WhatsApp -> User: Show [onboarding messages]
    end
@enduml

WhatsApp phone OTP (LoA2) authentication

Operational flow based on the whatsapp-otp-login global dialog.

The flow will be similar for email OTP method.

@startuml
title: WhatsApp authentication flow via phone OTP (LoA2)
    actor User
    participant WhatsApp #f6b5ff
    participant KernelWhatsAppApi #99FFFF
    participant AuraBridge #1add4d
    participant AuraGroot #76bbe7
    participant AuthenticationApi #FFFF99
    participant AuraBot #41a0f9 
    participant TACApi #66B2FF
    participant KernelAuthServer #99FFFF
    participant KernelUserProfileApi #99FFFF
    participant AuraBridgeOutbound #1add4d

    User -> WhatsApp: I want to log in
    WhatsApp -> KernelWhatsAppApi: I want to log in
    KernelWhatsAppApi -> AuraBridge: I want to log in
    AuraBridge -> KernelWhatsAppApi: 200 OK
    AuraBridge -> AuraGroot: I want to log in
    AuraGroot -> AuraBridge: 200 OK
    AuraGroot -> AuraGroot: GetSkillByChannel
    AuraGroot -> AuraBot: Request [message]
    AuraBot -> AuraGroot: 200 OK
    note left of AuraGroot: See basic WhatsApp flow for anonymous users
    AuraBot -> AuraBot: basic whatsapp flow for anonymous user
    AuraBot -> AuraBot: Dialog needs auth and user is anonymous. Redirect to WhatsApp login dialog, step 1
    AuraBot -> AuraGroot: Send [Please, enter your phone number]
    AuraGroot -> AuraBot: 200 OK
    AuraGroot -> AuraBridgeOutbound: Send [Please, enter your phone number]
    AuraBridgeOutbound -> KernelWhatsAppApi: Send [Please, enter your phone number]
    KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
    KernelWhatsAppApi -> WhatsApp: Send [Please, enter your phone number]
    WhatsApp -> User: Send [Please, enter your phone number]
    User -> WhatsApp: phoneNumber
    WhatsApp -> KernelWhatsAppApi: phoneNumber
    KernelWhatsAppApi -> AuraBridge: phoneNumber
    AuraBridge -> KernelWhatsAppApi: 200 OK
    AuraBridge -> AuraGroot: phoneNumber
    AuraGroot -> AuraBridge: 200 OK
    AuraGroot -> AuraBot: phoneNumber
    AuraBot -> AuraGroot: 200 OK
    AuraBot -> AuraBot: Execute step 2 of WhatsApp login dialog
    AuraBot -> KernelWhatsAppApi: POST sendSMSOTPCode(phoneNumber)
    KernelWhatsAppApi -> AuraBot: 200 OK
    KernelWhatsAppApi -> User: [SMS] Your verification code is XXXX
    AuraBot -> AuraGroot: Send [Please, enter your phone number]
    AuraGroot -> AuraBot: 200 OK
    AuraGroot -> AuraBridgeOutbound: Send [Please, enter your phone number]
    AuraBridgeOutbound -> KernelWhatsAppApi: Send [Please, enter your phone number]
    KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
    KernelWhatsAppApi -> WhatsApp: Send [Please, enter your phone number]
    WhatsApp -> User: Send [Please, enter the verification code]
    User -> WhatsApp: XXXX
    WhatsApp -> KernelWhatsAppApi: XXXX
    KernelWhatsAppApi -> AuraBridge: XXXX
    AuraBridge -> KernelWhatsAppApi: 200 OK
    AuraBridge -> AuraGroot: XXXX
    AuraGroot -> AuraBridge: 200 OK
    AuraGroot -> AuraBot: XXXX
    AuraBot -> AuraGroot: 200 OK
    AuraBot -> AuraBot: Execute step 3 of WhatsApp login dialog
    AuraBot -> KernelWhatsAppApi: POST validateCode(phoneNumber, code)
    KernelWhatsAppApi -> AuraBot: 200 OK {authenticationContext}
    AuraBot -> AuthenticationApi: POST /users/auraId {authenticationContext}
    AuthenticationApi -> AuraBot: 201 Created
    alt  User has already accepted authenticated Terms and Conditions
        AuraBot -> TACApi: GET termsAndConditions(auraId)
        TACApi -> AuraBot: 200 OK
        AuraBot -> AuraGroot: Send [Great! you are now signed in]
        AuraGroot -> AuraBot: 200 OK
        AuraGroot -> AuraBridgeOutbound: Send [Great! you are now signed in]
        AuraBridgeOutbound -> AuraGroot: 200 OK
        AuraBridgeOutbound -> KernelWhatsAppApi: Send [Great! you are now signed in]
        KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
        KernelWhatsAppApi -> WhatsApp: Send [Great! you are now signed in]
        WhatsApp -> User: Show [Great! you are now signed in]
    else User needs to accept authenticated T&C
        AuraBot -> TACApi: GET termsAndConditions(auraId)
        TACApi -> AuraBot: 404 Not found
        AuraBot -> AuraGroot: Send [Great! you are now signed in]
        AuraGroot -> AuraBot: 200 OK
        AuraGroot -> AuraBridgeOutbound: Send [Great! you are now signed in]
        AuraBridgeOutbound -> AuraGroot: 200 OK
        AuraBridgeOutbound -> KernelWhatsAppApi: Send [Great! you are now signed in]
        KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
        KernelWhatsAppApi -> WhatsApp: Send [Great! you are now signed in]
        WhatsApp -> User: Show [Great! you are now signed in]
        AuraBridgeOutbound -> AuraGroot: intent.onboarding.terms-and-conditions from redirect intent configured for the channel
        AuraGroot -> AuraBridgeOutbound: 200 OK
        AuraGroot -> AuraBot: intent.onboarding.terms-and-conditions from redirect intent configured for the channel
        AuraBot -> AuraGroot: 200 OK
        AuraBot -> AuraBot: GET userCache(auraId)
        opt User is not in cache
            AuraBot -> AuthenticationApi: GET AuraId
            AuthenticationApi -> AuraBot: 200 OK {userData}
            AuraBot -> KernelAuthServer: POST /token
            Note over AuraBot,KernelAuthServer: Here, a 3legged accessToken is requested
            KernelAuthServer -> AuraBot: {token}
            AuraBot -> KernelAuthServer: getIntrospect(token)
            opt channel allows UserProfile
                AuraBot -> KernelUserProfileApi: getUserProfile(userId)
                KernelUserProfileApi -> AuraBot: UserProfile
            end
            AuraBot -> AuraBot: store user in cache: userData, userProfile, valid scopes and purposes
        end
        AuraBot -> AuraBot: executes Terms and Conditions dialog
        AuraBot -> AuraGroot: Send [onboarding messages]
        AuraGroot -> AuraBot: 200 OK
        AuraGroot -> AuraBridgeOutbound: Send [onboarding messages]
        AuraBridgeOutbound -> AuraGroot: 200 OK
        AuraBridgeOutbound -> KernelWhatsAppApi: Send [onboarding messages]
        KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
        KernelWhatsAppApi -> WhatsApp:  Send [onboarding messages]
        WhatsApp -> User: Show [onboarding messages]
    else Channel doesn't have terms and conditions config
        AuraBot -> AuraGroot: Send [Great! you are now signed in]
        AuraGroot -> AuraBot: 200 OK
        AuraGroot -> AuraBridgeOutbound: Send [Great! you are now signed in]
        AuraBridgeOutbound -> AuraGroot: 200 OK
        AuraBridgeOutbound -> KernelWhatsAppApi: Send [Great! you are now signed in]
        KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
        KernelWhatsAppApi -> WhatsApp: Send [Great! you are now signed in]
        WhatsApp -> User: Show [Great! you are now signed in]
    end
@enduml

WhatsApp logout

Operational flow based on the whatsapp-logout global dialog.

@startuml
title: WhatsApp logout flow
    actor User
    participant WhatsApp #f6b5ff
    participant KernelWhatsAppApi #99FFFF
    participant AuraBridge #1add4d
    participant AuraGroot #76bbe7
    participant AuthenticationApi #FFFF99
    participant AuraBot #41a0f9 
    participant KernelAuthServer #99FFFF
    participant KernelUserProfileApi #99FFFF
    participant AuraBridgeOutbound #1add4d

    User -> WhatsApp: I want to logout
    WhatsApp -> KernelWhatsAppApi: I want to logout
    KernelWhatsAppApi -> AuraBridge: I want to logout
    AuraBridge -> KernelWhatsAppApi: 200 OK
    AuraBridge -> AuraGroot: I want to logout
    AuraGroot -> AuraBridge: 200 OK
    AuraGroot -> AuraBot: I want to logout
    AuraBot -> AuraGroot: 200 OK
    AuraBot -> AuraBot: Basic whatsapp flow for authenticated users
    AuraBot -> AuthenticationApi: DELETE /users/auraId
    AuthenticationApi -> AuraBot: 204 NO_CONTENT
    AuraBot -> KernelWhatsAppApi: DELETE /sessions/authorizationId
    KernelWhatsAppApi -> AuraBot: 204 NO_CONTENT
    AuraBot -> AuraGroot: Send [You're successfully logged out, discover what can be done with Aura]
    AuraGroot -> AuraBot: 200 OK
    AuraGroot -> AuraBridgeOutbound: Send [You're successfully logged out, discover what can be done with Aura]
    AuraBridgeOutbound -> AuraGroot: 200 OK
    AuraBridgeOutbound -> KernelWhatsAppApi: Send [You're successfully logged out, discover what can be done with Aura]
    KernelWhatsAppApi -> AuraBridgeOutbound: 200 OK
    KernelWhatsAppApi -> WhatsApp: Send [You're successfully logged out, discover what can be done with Aura]
    WhatsApp -> User: Show [You're successfully logged out, discover what can be done with Aura]
@enduml