0

I have Customized chat window and I need to connect with salesforce live agent so I integrated LiveAgent API of salesforce. For closing the chat I trigger end chat API I am getting 200 response but chat window is not closing.

endChat(userId: string){

        let objArr: User[] = JSON.parse(localStorage.getItem('userCreden'));
        let len = objArr.length;
        let user: User;
        for (let i = 0; i < len; i++) {
            if (userId == objArr[i].userId) {
                user = objArr[i];
                break;
            }
        }

        let sessionIdRespParsed = user.sessresp;

        let live_agent_url = this.appConfig.getConfig().live_agent_server_url;
        this.httpClient.post<HttpResponse<string>>(live_agent_url + '/chat/rest/Chasitor/ChatEnd', {
            "reason":"client"
        }, {
                headers: new HttpHeaders({
                    'X-LIVEAGENT-API-VERSION': '34',
                    'X-LIVEAGENT-AFFINITY': sessionIdRespParsed.affinityToken,
                    'X-LIVEAGENT-SESSION-KEY': sessionIdRespParsed.key,
                    'X-LIVEAGENT-SEQUENCE': '1'
                })
        }).subscribe(
            res => {
                console.log("response of Chat end  " + res);
            },
            err => {

            }
        );
    }
  • 1
    Welcome to sfse, please take some time to read How to Ask and take the tour. Once you have done so, make sure you include the relevant code (preferable, minimal reproducible code sample) and a clear description of the problem alongside any errors. – Eduard Jul 19 '18 at 9:30
  • @Eduard i am new to StackExchange next time i will take care. :). You have solution of my error i am getting 200 response code but still chat is not closing. – Shivam Kumar Jul 19 '18 at 9:54
0

I don't know if this is still relevant to you. But I had the same issue and it seems like simply deleting this header:

'X-LIVEAGENT-SEQUENCE': '1'

does the trick.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.