Initialization
initialize the sdk the first step to use the kindly sdk is to initialize it with your bot key and market slug kindlysdk start( application = application, botkey = "your bot key", languagecode = "en", market = "your market" ) you can also provide an authentication token provider if your bot requires authentication kindlysdk start( application = application, botkey = "your bot key", languagecode = "en", market = "your market", authtokenprovider = kindlyauthtokenprovider { request > // suspend code â return a jwt for request chatid fetchjwtfrombackend(request chatid) } ) for more details on authentication, see using authentication authentication md markets (per location settings) bots can serve their ui, greeting, and responses per market the market slug is required â pass the market configured for your bot kindlysdk start( application = application, botkey = "your bot key", languagecode = "en", market = "eu" ) the sdk loads that market's settings and tells the backend which market was picked (so greeting/responses are localized to it) if the market's settings can't be loaded the chat won't load â there is no fallback to another market and no per bot default settings find your market slugs in the kindly platform (settings â general â details & markets) see the markets markets md guide for details change language at runtime you can change the language after initialization using kindlysdk setlanguage("lt") // change to lithuanian this method will call the language switch api update the cached settings refresh ui translations notify all ui components of the language change the language setting will persist across chat sessions until explicitly changed bot switching and reinitialization the sdk intelligently handles bot switching and reinitialization scenarios when you call start() multiple times with different parameters automatic bot key switching when you call start() with a different bot key , the sdk automatically detects the change compares the new bot key with the current one performs cleanup calls endchat() internally to end the current session resets state clears sdk initialization flags and session data reinitializes connects to the new bot seamlessly // first initialization kindlysdk start(application = this, botkey = "bot key 1", market = "your market") kindlysdk launchchat(context = this) // later, switch to different bot automatic cleanup happens kindlysdk start(application = this, botkey = "bot key 2", market = "your market") // sdk handles cleanup internally kindlysdk launchchat(context = this) connection state handling when the sdk is disconnected (e g , after calling endchat() ), calling start() with the same bot key will reconnect kindlysdk start(application = this, botkey = "your bot key", market = "your market") kindlysdk launchchat(context = this) // later, end the chat kindlysdk endchat() // reconnect with same bot key allowed reconnection kindlysdk start(application = this, botkey = "your bot key", market = "your market") // reconnects instead of skipping kindlysdk launchchat(context = this) skipping duplicate initialization the sdk skips initialization only when all conditions are met same bot key still connected (not disconnected) kindlysdk start(application = this, botkey = "your bot key", market = "your market") // this second call will be skipped no changes needed kindlysdk start(application = this, botkey = "your bot key", market = "your market") best practices for bot switching option 1 automatic switching (recommended) // sdk handles cleanup automatically kindlysdk start(application = this, botkey = "new bot key", market = "your market") kindlysdk launchchat(context = this) option 2 explicit end then start // explicit control over the lifecycle kindlysdk endchat() // endchat() completes synchronously, so you can immediately call start() kindlysdk start(application = this, botkey = "new bot key", market = "your market") kindlysdk launchchat(context = this) both approaches work identically choose based on your preference for explicit vs automatic lifecycle management