You need to sign in to do that
Don't have an account?
Saurabh Kulkarni 76
embedded_svc.liveAgentAPI.startChat doesn't work
Hello Guys,
I have been using embedded service for a while, I wanted to hide the standard button and start the chat with some custom button and for that I tried to use below code snippent. However, it gives me error all the time as Cannot read property "startChat" of undefined. If I print the object embedded_svc in the console, it comes fine. However, embedded_svc.liveAgentAPI gives and error. Can you please help what may have gone wrong?
I have been using embedded service for a while, I wanted to hide the standard button and start the chat with some custom button and for that I tried to use below code snippent. However, it gives me error all the time as Cannot read property "startChat" of undefined. If I print the object embedded_svc in the console, it comes fine. However, embedded_svc.liveAgentAPI gives and error. Can you please help what may have gone wrong?
embedded_svc.liveAgentAPI.startChat({ directToAgentRouting: { buttonId: “573xx0000000000”, // userId: “”, fallback: true }, extraPrechatInfo: [], extraPrechatFormDetails: [] });
Please check if you have missed out to implement the showWhenOnline correctly in your code snippet, which should work when an agent is online.
See similar issue discussed here:
https://salesforce.stackexchange.com/questions/114132/live-agent-issue-with-startchat
Hope above information helps, Please mark as Best Answer so that it can help others in the future.
Thanks.
You can try something like to add a button which trigger a function that call startChat which should work.
embedded_svc has an addEventHandler method that you can use to observe when everything is ready, and call startChat after it has been iniatilized (or after the availability check has been completed).
Something like:
You can read more about these events and what they are for here: https://developer.salesforce.com/docs/atlas.en-us.snapins_web_dev.meta/snapins_web_dev/snapins_web_chat_events.htm?search_text=onSettingsCallCompleted