AIConversationKit component in a short time. Following this guide, you will complete the following key steps within 20 minutes and implement a conversational AI project with a complete UI.Conversational AI Interface ![]() |
|
aiconversatonkit subdirectory under the Android directory to the same-level directory of the app in your current project, as shown in the figure below:
setting.gradle (or settings.gradle.kts) file in the project root directory, and add the following code in it. It enables importing the aiconversationkit component into your current project.include ':aiconversationkit'
include (":aiconversationkit")
build.gradle (or build.gradle.kts) file under the app directory, and add the following code in it. It enables the current app to depend on the newly added aiconversationkit component.api project(':aiconversationkit')
api(project(":aiconversatonkit"))
-keep class com.tencent.** { *; }
tools:replace="android:allowBackup" in the application node. Override the settings within the component and use your own settings.// app/src/main/AndroidManifest.xml<applicationandroid:name=".DemoApplication"android:allowBackup="false"android:icon="@drawable/app_ic_launcher"android:label="@string/app_name"android:largeHeap="true"android:theme="@style/AppTheme"tools:replace="android:allowBackup">
TUILogin. This step is critical because only after logging in can AIConversationkit features be used normally. Please patiently check if the relevant parameters are configured correctly.String userId = "denny"; // Please replace with your UserIDint sdkAppId = 1400000001; // Please replace with the sdkAppId obtained in step 1String sdkSecretKey = "xxxx"; // Please replace with the sdkSecretKey obtained in step 1String userSig = GenerateTestUserSig.genTestUserSig(sdkAppId, userId, sdkSecretKey);TUILogin.login(this, sdkAppId, userId, userSig, new TUICallback() {@Override public void onSuccess() {}@Override public void onError(int errorCode, String errorMessage) {}});
val userId = "denny" // Please replace with your UserIDval sdkAppId = 1400000001 // Please replace with the sdkAppId obtained in step 1val sdkSecretKey = "xxxx" // Please replace with the sdkSecretKey obtained in step 1val userSig = GenerateTestUserSig.genTestUserSig(sdkAppId, userId, sdkSecretKey)TUILogin.login(this, sdkAppId, userId, userSig, object : TUICallback() {override fun onSuccess() {}override fun onError(errorCode: Int, errorMessage: String) {}})
Parameter | Type | Description |
userId | String | Customers customize their Custom User IDs according to their own business, which only allow a combination of uppercase and lowercase letters (a-z A-Z), numbers (0-9), underline and hyphen. |
sdkAppId | int | |
secretKey | String | |
userSig | String | A security protection signature used for user login authentication to confirm the authenticity of the user and prevent malicious attackers from misappropriating your cloud service usage rights. |
GenerateTestUserSig.genTestSig function to generate userSig. In this method, the SDKSecretKey can be easily decompiled and reverse cracked. Once your key leaks, attackers can unauthorized use your Tencent Cloud traffic.AIConversationDefine.StartAIConversationParams startParams = new AIConversationDefine.StartAIConversationParams();int sdkAppId = 1400000001; // 1,Replace your sdkAppIdString sdkSecretKey = "xxxx"; // 2,Replace your sdkSecretKeyString aiRobotId = "robot_" + TUILogin.getUserId();String aiRobotSig = GenerateTestUserSig.genTestUserSig(sdkAppId, aiRobotId, sdkSecretKey);startParams.agentConfig = AIConversationDefine.AgentConfig.generateDefaultConfig(aiRobotId, aiRobotSig);startParams.secretId = "xxx"; // 3,Replace your secretIdstartParams.secretKey = "xxx"; // 4,Replace your secretKey// 5,Replace your llmConfigstartParams.llmConfig = "{\\"LLMType\\":\\"openai\\",\\"Model\\":\\"hunyuan-turbo-latest\\",\\"SystemPrompt\\":\\"You are a private assistant\\",\\"APIUrl\\":\\"https:xxx\\",\\"APIKey\\":\\"xxx\\",\\"History\\":5,\\"Streaming\\":true}";// 6,Replace your ttsConfigstartParams.ttsConfig = "{\\"TTSType\\":\\"tencent\\",\\"AppId\\":\\"xxx\\",\\"SecretId\\":\\"xxx\\",\\"SecretKey\\":\\"xxx\\",\\"VoiceType\\":\\"502001\\",\\"Speed\\":1.25,\\"Volume\\":5,\\"PrimaryLanguage\\":1,\\"FastVoiceType\\":\\"\\"}";Intent intent = new Intent(this, AIConversationActivity.class);intent.putExtra(KEY_START_AI_CONVERSATION, startParams);startActivity(intent);
val startParams = AIConversationDefine.StartAIConversationParams()val sdkAppId = 1400000001 // 1,Replace your sdkAppIdval sdkSecretKey = "xxxx" // 2,Replace your sdkSecretKeyval aiRobotId = "robot_" + TUILogin.getUserId()val aiRobotSig = GenerateTestUserSig.genTestUserSig(sdkAppId, aiRobotId, sdkSecretKey)startParams.agentConfig = AIConversationDefine.AgentConfig.generateDefaultConfig(aiRobotId, aiRobotSig)startParams.secretId = "xxx" // 3,Replace your secretIdstartParams.secretKey = "xxx" // 4,Replace your secretKey// 5,Replace your llmConfigstartParams.llmConfig = "{\\"LLMType\\":\\"openai\\",\\"Model\\":\\"hunyuan-turbo-latest\\",\\"SystemPrompt\\":\\"You are a private assistant\\",\\"APIUrl\\":\\"https:xxx\\",\\"APIKey\\":\\"xxx\\",\\"History\\":5,\\"Streaming\\":true}"// 6,Replace your ttsConfigstartParams.ttsConfig = "{\\"TTSType\\":\\"tencent\\",\\"AppId\\":\\"xxx\\",\\"SecretId\\":\\"xxx\\",\\"SecretKey\\":\\"xxx\\",\\"VoiceType\\":\\"502001\\",\\"Speed\\":1.25,\\"Volume\\":5,\\"PrimaryLanguage\\":1,\\"FastVoiceType\\":\\"\\"}"val intent = Intent(this, AIConversationActivity::class.java)intent.putExtra(KEY_START_AI_CONVERSATION, startParams)startActivity(intent)

startParams.secretId and startParams.secretKey.startParams.llmConfig, and copy the string value corresponding to TTSConfig to startParams.ttsConfig.Feedback