Yeldaai / chat-plugin

Yelda Chat Plugin
MIT License
0 stars 0 forks source link

related to Yeldaai/yelda#5145 - fetch chat bubble from external endpo… #119

Closed codebynao closed 2 years ago

codebynao commented 2 years ago

…int in priority

In onreadystatechange, I noticed that we were returning JSON.parse(xhr.responseText).data but while testing on the demo page, I never got the .data. I didn't remove it yet because I'm not sure 100% it wouldn't affect prod chats. As I explained in a comment, from my tests, the setting is received directly as { ...webchatSettings } from both the external endpoint and the yelda endpoint. But as I didn't work on this part before, I thought that I might miss a case where we get the .data otherwise we would have some broken cases in prod, no?

codebynao commented 2 years ago

I spent quite some time debugging some tests that were failing because getAssistantSettings was returning null instead of the webchat settings for the mock data.

After some time I found out that it was because I was adding the env query to the chatBubble urls in getAssistantSettingsUrl In the test file, I had to update the URLs in testAPIUrls and add the env in the validMockData for the tests to work again.

I guess that xhr-mock compares the testAPIUrls to the one that is actually called but they were different because one had the env query and the other didn't. However, I have to admit that I don't know what I had to add the env to validMockData for it to work since the production env is used by default...

meelie commented 2 years ago

Points to recheck


Local test ​in index.html

staging with assistantId

 yeldaChat.init({
        'assistantSlug': 'fm_logistic',
        'assistantId': '5b7edb2c1060312cfeaa7981',
        'assistantUrl': 'https://app.yelda.ai',
        'chatPath': '/chat',
        'locale': 'fr_FR',
        'isAdmin': true, // Used to see the NLP logs
        'shouldBeOpened': true // open the chat window by default on loading the page if set to true
      })
  1. https://webchat.yelda.ai/webchat/5b7edb2c1060312cfeaa7981/chatBubble/fr_FR?env=production no answer
  2. https://app.yelda.ai/assistants/5b7edb2c1060312cfeaa7981/chatBubble/fr_FR?env=production default answer (not db one)
 yeldaChat.init({
        'env': 'staging',
        'assistantSlug': 'fm_logistic',
        'assistantId': '5b7edb2c1060312cfeaa7981',
        'assistantUrl': 'https://app.yelda.ai',
        'chatPath': '/chat',
        'locale': 'fr_FR',
        'isAdmin': true, // Used to see the NLP logs
        'shouldBeOpened': true // open the chat window by default on loading the page if set to true
      })

with staging env defined => https://webchat.yelda.ai/webchat/5b7edb2c1060312cfeaa7981/chatBubble/fr_FR?env=staging return the correct data directly

prod with setting id (krds)

 yeldaChat.init({
        'settingId': '5e7ccb230729870f7921375c',
        'isAdmin': true, // Used to see the NLP logs
        'shouldBeOpened': true // open the chat window by default on loading the page if set to true
      })

no response https://webchat.yelda.ai/webchat/settings/5e7ccb230729870f7921375c/chatBubble?env=production because it has been never used

fallback on good old https://app.yelda.ai/assistants/settings/5e7ccb230729870f7921375c/chatBubble?env=production which works

SO I think we're good, what do you think ?