How to authenticate with iAdvize in client's website?

To enforce a proper secured visitor authentication, the authentication mode needs to be activated. Therefore, the iAdvize tag will wait for an “authentication” instruction before loading and engaging the visitor in a conversation. It differs from the standard non-authenticated mode.

However, it is also possible to let the visitor chat in an anonymous way with authenticated mode on. Details are provided below.

Include the tag

You can dispatch the authentication instruction before the tag is included, or after. Either way, you will need to include the main iAdvize tag this way:

<script> 
window.iAdvizeInterface = window.iAdvizeInterface || []; 
iAdvizeInterface.config = { 
        sid: '<YOUR-SITE-ID>' 
} 
</script> 
<script async src="//<YOUR-PLATFORM>.iadvize.com/iadvize.js"></script>

You will need to replace `<YOUR-SITE-ID>` with your actual site ID, which can be found on the admin : https://ha.iadvize.com/admin/site/current/code

Activate the tag with an identity

When the authenticated mode is on, the tag won’t activate until an authentication instruction is dispatched.

  • Case A - if the visitor needs a real signed in identity from the client server needs, the system waits for a token,

  • Case B - if the visitor can chat without a real identity, use an anonymous authentication. If the visitor later signs in (see next section), the conversation will continue - either with the content of the previous signed in conversation (if it exists), or with the content of the previously anonymous conversation.

// Secured authentication - case A 
iAdvizeInterface.push((iAdvize) => { 
        iAdvize.activate(async () => { 
                const visitor_token = await ... // your backend logic to generate a JWE 
                return { 
                        authenticationOption : { type: 'SECURED_AUTHENTICATION', token: visitor_token } 
                }; 
         }); 
}); 

// OR Anonymous authentication - case B 
iAdvizeInterface.push((iAdvize) => { 
        iAdvize.activate(() => ({ 
                authenticationOption: { type: 'ANONYMOUS' } 
        })); 
});

Provide an identity after an anonymous activation

A common scenario would be a visitor that arrives anonymously on your website, then signs in their authenticated space.

In this scenario, the Case B mentioned above for the activation has been chosen. Which means the tag has been activated anonymously, using this line:

iAdvizeInterface.push((iAdvize) => {
        iAdvize.activate(() => ({ authenticationOption: { type: 'ANONYMOUS' } }));
});

Now, after a successful sign-in, the client needs to feed the iAdvize tag with the token authenticating the visitor. This can be done by triggering the same "activate" method:

const afterLoginIadvizeIdentityCallback = () => { 
        iAdvizeInterface.push((iAdvize) => { 
                iAdvize.activate(async () => { 
                        const visitor_token = await ... // your backend logic to generate a JWE 
                        return { 
                            authenticationOption : { type: 'SECURED_AUTHENTICATION', token: visitor_token }; 
                        }; 
                 }); 
         }); 
}; // it is the brand responsibility to trigger such callback after sign-in

What happens to an ongoing anonymous conversation when the visitor signs in?

If the visitor was chatting anonymously, then signed in:

  • they will keep their ongoing conversation if they do not have an ongoing conversation in their authenticated space

  • they will get their previous conversation back if they chatted while authenticated before

Conversation scenarios

Conversation scenario

Scenario

1

Across multiple computers / browsers

  • Sarah visits the website on her personal mobile

  • Sarah starts a conversation as an anonymous visitor

  • Sarah authenticates in the customer space, and can continue her conversation

  • Sarah visits again the day after (whatever the delay) on her professional computer

  • Sarah authenticates in the customer space

  • Sarah sees her ongoing conversation again

2

  • Sarah visits the mobile site on her smartphone / tablet etc.

  • Sarah starts a conversation as an anonymous visitor

  • Sarah’s conversation is closed or not by an agent

  • Sarah visits the mobile app on her smartphone / tablet etc.

  • Sarah authenticates in the customer space

  • Sarah doesn’t see her ongoing conversation or closed conversation, she can just see the last authenticated conversation - Coming in v2.6 of the mobile SDK

3

Multiple on-going conversation

  • Sarah visits the mobile site on her smartphone / tablet etc.

  • Sarah authenticates in the customer space

  • Sarah starts a conversation, but leaves it open

  • Sarah visits again the day after (whatever the delay) on her computer

  • Sarah starts a conversation as an anonymous visitor

  • Sarah authenticates in her customer space

  • Sarah starts a conversation

  • Sarah sees the on-going conversation she created on her smartphone, and she can’t continue the anonymous conversation she just created. If she wants to get back at her anonymous conversation, she has to logout.

4

Expired Session

  • Sarah visits the mobile site on her smartphone / tablet etc.

  • Sarah authenticates in the customer space

  • Sarah starts a conversation, and leaves it open

  • Sarah leaves the site without logout, and visits again the day after (whatever the delay) on her smartphone / tablet etc. The session has expired, she’s not authenticated anymore. She can’t see anymore the conversation.

  • Sarah authenticates in the customer space

  • Sarah sees her ongoing conversation again

5

Multiple visitors

  • Sarah visits the website on her family computer

  • Sarah starts a conversation as an anonymous visitor

  • Sarah’s conversation is not closed by an agent

  • Sarah leave the website

  • Paul visits the website the day after (whatever the delay) on the same computer

  • Paul authenticates in the customer space

  • If Paul never had an authenticated conversation before, he sees Sarah’s on-going anonymous conversation. But if he already have one, then he sees his conversation and not Sarah’s.

Last updated