Direct Line flowcharts

Basic flows for Direct Line channels

Request a new accessToken from Direct Line to access Aura

These steps must be executed before starting the user conversation with Aura. The token to access Direct Line must be requested to Aura because one of the admin secrets of the bot Direct Line configuration is used to generate the tokens.

@startuml
    title: Request a DirectLine accessToken for AuraGroot
    participant Channel #bdf492
    participant DirectLine #FFCC99
    participant DirectLineWebsocket #FFCC99
    participant AuthenticationApi #FFFF99

    Channel -> AuthenticationApi: POST /aura-services/v1/token/wss
    AuthenticationApi -> DirectLine: POST /token
    DirectLine -> AuthenticationApi: 201 Created {token}
    AuthenticationApi -> Channel: 201 Created {token}
    Channel -> DirectLine: Open WebSocket
    Channel -> DirectLine: Start sending user requests
    Channel -> DirectLineWebSocket: Start getting Aura responses
@enduml

New Direct Line message from anonymous users

An anonymous user is the one that has never been authenticated via Kernel and her authentication session has not been stored in aura-authentication-api.

Find more information in the document Channels authentication: anonymous users

@startuml

title: Basic flow for DirectLine anonymous users


    actor User
    participant Channel #bdf492
    participant DirectLine #FFCC99
    participant DirectLineWebsocket #FFCC99
    participant AuthenticationApi #FFFF99
    participant AuraGroot #76bbe7
    participant AuraBot #41a0f9 

    Channel -> DirectLineWebsocket: Open WebSocket
    User -> Channel: Send [message]
    Note over Channel,DirectLine: The previously created token of DirectLine must be sent in the Authorization header as Bearer token.
    Channel -> DirectLine: Send {activity[message]}
    DirectLine -> AuraGroot: Send {activity[message]}
    AuraGroot -> DirectLine: 200 OK
    note right of AuraGroot: KPI entities are stored during Middlewares execution in local memory.\nEvery 2 minutes and before closing a POD, they are written in Azure Storage.
    AuraGroot -> AuraGroot: Middlewares
    AuraGroot -> AuraGroot: Recognizers (GetSkillByChannel)
    AuraGroot -> AuraBot: Send {activity[message]}
    Note over AuraGroot,AuraBot: There are two different conversations: one between the channel and AuraGroot and another one between AuraGroot and the skill.
    AuraBot -> AuraGroot: 200 OK
    AuraBot -> AuthenticationApi: GET AuraId
    AuthenticationApi -> AuraBot: 404 Not found (Anonymous)
    AuraBot -> AuraBot: Middlewares
    note right of AuraBot: KPI entities are stored during Middlewares execution in local memory.\nEvery 2 minutes and before closing a POD, they are written in Azure Storage.
    AuraBot -> AuraBot: Recognizers
    AuraBot -> AuraBot: Main Dialog
    AuraBot -> AuraBot: Execute Specific functional Dialog
    AuraBot -> AuraGroot: Send {responseActivity}
    AuraGroot -> AuraBot: 200 OK
    AuraGroot -> DirectLine: Send {responseActivity}
    DirectLine -> AuraGroot: 200 OK
    Channel -> DirectLineWebsocket: Read {responseActivity}
    Channel -> User: Show {responseActivity}
@enduml

New Direct Line message from authenticated users

Find information regarding users’ authentication in the document Channels authentication: authenticated users.

@startuml

title: Basic flow for DirectLine authenticated users

    actor User
    participant Channel #bdf492
    participant DirectLine #FFCC99
    participant DirectLineWebsocket #FFCC99
    participant AuthenticationApi #FFFF99
    participant AuraGroot #76bbe7
    participant AuraBot #41a0f9 
    participant KernelAuthServer #99FFFF
    participant KernelUserProfileApi #99FFFF
    
    Channel -> DirectLineWebsocket: Open WebSocket
    User -> Channel: Send [message]
    Note over Channel,DirectLine: The previously created token of DirectLine must be sent in the Authorization header as Bearer token.
    Channel -> DirectLine: Send {activity[message]}
    DirectLine -> AuraGroot: Send {activity[message]}
    AuraGroot -> DirectLine: 200 OK
    Note right of AuraGroot: KPI entities are stored during Middlewares execution in local memory.\nEvery 2 minutes and before closing a POD, they are written in Azure Storage.
    AuraGroot -> AuraGroot: Middlewares
    AuraGroot -> AuraGroot: Recognizers (GetSkillByChannel)
    AuraGroot -> AuraBot: Send {activity[message]}
    Note over AuraGroot,AuraBot: There are two different conversations: one between the channel\nand AuraGroot and another one between AuraGroot and the skill.
    AuraBot -> AuraGroot: 200 OK
    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: Middlewares
    Note right of AuraBot: KPI entities are stored during Middlewares execution in local memory.\nEvery 2 minutes and before closing a POD, they are written in Azure Storage.
    AuraBot -> AuraBot: Recognizers
    AuraBot -> AuraBot: Main Dialog
    AuraBot -> AuraBot: ValidateAuthenticationForDialog
    AuraBot -> AuraBot: Execute Specific functional Dialog
    AuraBot -> AuraGroot: Send {responseActivity}
    AuraGroot -> AuraBot: 200 OK
    AuraGroot -> DirectLine: Send {responseActivity}
    DirectLine -> AuraGroot: 200 OK
    Channel -> DirectLineWebsocket: Read {responseActivity}
    Channel -> User: Show {responseActivity}
@enduml