Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Unable to retrieve chat info for chat open when AAE is opened #12

Open
IndigoLogic opened this issue Sep 3, 2019 · 3 comments
Open

Comments

@IndigoLogic
Copy link

Our ultimate objective is to be able to fetch the email of the current user to authenticate with our application, and then to be able to coordinate our application to the current chat. Here is a summary of the current order of operations, from what I have been able to determine, including commentary on our issue:

  1. The agent logs into the LiveChat application

  2. A customer chats into the app

  3. The agent accepts or is assigned the chat, and clicks on the icon to open the AAE

  4. The AAE calls our locally run application at https://localhost:8000/agent/livechat/oauth?plugin_id=11MRpkuo7

  5. Our application then calls the LiveChat oAuth service at https://accounts.livechatinc.com/?response_type=token&client_id=ca680abcc11f3b1224d1b519e7c6a958&redirect_uri=https://localhost:8000/agent

  6. The authentication call returns the token as part of the URL hash in a redirect to https://localhost:8000/agent. (NOTE: because the token is returned in the URL hash instead of payload, we are only able to access the token from the client-side application, which means that our check of the email cannot take place until the react component at that route is loaded in the iFrame)

  7. Our application uses the token to call https://accounts.livechatinc.com/info, and then uses the entity_id attribute to get the email, which we then use to authenticate the user in our react app. A JWT token is created in the app and added to the Redux store for the AAE to use in future api calls against our system. This happens with a reducer call to the url https://localhost:8000/api/agent/authorize/livechat

  8. Once this process is successful, we activate the SDK and add a listener to the on.customer_profile event with the following code:

    createDetailsWidget() // Initiates the LiveChat SDK widget then begins listening for the 'customer_profile' event
    .then(widget => {widget.on('customer_profile', profile =>
    {fetchOpportunityData(profile.chat.id, profile.chat.groupID, profile)
    })

The fetchOpportuhityData() function gets our matching client information (based on the chat group) and loads it into the AAE for the agent to use as a call script. It also creates a record for the chat in our database.
9. At this point, if there is only a single chat active, there is no way to cause the customer_profile event to re-fire. If a second person chats in, the customer_profile event fires and the AAE responds correctly. Once you have clicked off the initial chat and back on, everything is fine. It’s just that initial load where the AAE has not already been authorized before the chat occurs that is an issue.

I did try activating the widget before the authorization, but I get a timeout error and the widget does not load.

So, in order to solve this issue, is there a way to do one of the following?

• Evaluate the token or get the email for the logged-in user from the back-end through a payload or other source so that the validation can occur before the react component is loaded. (Since we can only evaluate the URL hash from the client side, we are unable to run our authorization code until the token has been returned).
• Re-fire the customer_profile event or run a call that will give us the information related to the current chat so that we can connect our AAE to the initially active chat.

Or, do you have any other suggestions on how we might resolve this order of operations conflict?

@IndigoLogic
Copy link
Author

As a further update, I tried adding a redirect component on the client side that would handle the login before logging into the AAE at all. However, it makes no difference - the initial chat still cannot be accessed from the AAE. Even if the AAE is already open, but then the last open chat is closed, the next chat in has the same issue.

@IndigoLogic
Copy link
Author

I have an .har file that might be helpful in tracking the issue, but I don't want to upload it here since it will contain some sensitive information. If you would like to contact me directly via email (heather@logicalblonde.com), I would be happy to send it to you.

@MichalPaszowski
Copy link
Contributor

Hey sorry for the late reply. I have tested this, and it seems that we have a bug. I have forwarded this to our developers, and I will drop an update as soon as I know something more.

I apologize for the inconvenience.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants