vue.jsnuxt.jsfacebook-messengerfacebook-chatbotfacebook-customer-chat

How to implement Facebook Messenger customer chat SDK in Nuxt, Vue?


i was doing this implementation with Facebook Messenger customer chat SDK into my Nuxt app.

Solution 1 (worked 0%):
I tried the https://www.npmjs.com/package/vue-fb-customer-chat package, and it didn't work, the package's site itself is down -.-! i import it and use it as a plugins and so on, i did as exactly as instructed, i even tried to use <VueFbCustomerChat /> and <vue-fb-customer-chat /> as extra too, but nothing seem to work!

Solution 2 (worked 50%):
Moreover, i tried to use it as a static file by creating a static file called fb-sdk.js and successfully deploy it:

window.fbAsyncInit = function() {
  FB.init({
    xfbml: true,
    version: "v6.0"
  })
}
;(function(d, s, id) {
  var js,
    fjs = d.getElementsByTagName(s)[0]
  if (d.getElementById(id)) return
  js = d.createElement(s)
  js.id = id
  js.src = "https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js"
  fjs.parentNode.insertBefore(js, fjs)
})(document, "script", "facebook-jssdk")

My result here, after using it as a static file plugin

but i got this error when begin to chat using it:

ErrorUtils caught an error:

a.substr is not a function. [Caught in: React reported an error]

Subsequent errors won't be logged; see https://fburl.com/debugjs.

The chat box came up and disappear, then it was no longer clickable @@

So please help me adding Facebook Messenger customer chat SDK into NuxtJS, is there a package? a step-by-step tutorial?


Solution

  • https://www.npmjs.com/package/vue-fb-customer-chat works, but the URL page must be https, for that reason it just works in production mode.