End Chat
disconnect the chat clears the context as well kindlysdk endchat() important the endchat() method now preserves the sdk initialization state this means â
the sdk remains initialized and ready for use â
you can call displaychat() again without needing to call start() â
bot key, authentication, and configuration are preserved â
only the active chat session and context are cleared if you need to completely terminate the sdk , use kill() kill sdk md instead bot switching workflows when switching between different bots, you have two workflow options option 1 automatic switching (recommended) the sdk automatically handles cleanup when you switch bot keys // current bot kindlysdk start(botkey "bot 1", market "your market") kindlysdk displaychat() // switch to different bot no explicit endchat() needed kindlysdk start(botkey "bot 2", market "your market") // sdk handles cleanup internally kindlysdk displaychat() option 2 explicit end then start for explicit control over the chat lifecycle // end current chat first kindlysdk endchat() then(on dispatchqueue main) { in // start with new bot after cleanup completes kindlysdk start(botkey "new bot key", market "your market") kindlysdk displaychat() } both approaches work identically the sdk ensures proper cleanup and reinitialization in both cases when to use endchat() use endchat() explicitly when you want to disconnect completely stop the chat service without switching to another bot clear session data ensure all messages and context are cleared explicit lifecycle control have fine grained control over connection timing the endchat() method returns a promise that resolves when cleanup is complete, allowing you to chain subsequent operations safely