I'm having issues with the Chatbot where it attempts to make a call to https://xxxx.zendesk.com/sc/sdk/v2/apps/xxxxxx/appusers/xxxxxxxx before I even attempt to Authenticate the user, this makes the request return 401. Is there a way I can prevent this call from being made before I authenticate???
Below is my react code.
const loadChatbotScript = () => {
constscriptId='ze-snippet'
if (document.getElementById(scriptId)) {
return
}
constzendeskScript=document.createElement('script')
zendeskScript.src=process.env.ZENDESK
zendeskScript.async=true
zendeskScript.id=scriptId
document.body.appendChild(zendeskScript)
zendeskScript.onload= () => {
window.zE('messenger:on', 'open', function () {
refetch()
})
}
}
useEffect(() => {
if (isAuthed) {
loadChatbotScript()
}
}, [isAuthed])
useEffect(() => {
if (token) {
window.zE('messenger', 'loginUser', callback=> {
callback(token)
})
}
}, [token])
isAuthedvar specifically is that even if it returned false in your application, the effect would fire and would lead to the issues that you're seeing.