本文將介紹在無需部署服務端的情況下,如何通過控制台產生的體驗Token,快速測試智能體。
說明
該方案僅供測試效果使用,不建議進行正式發布,否則可能導致shareToken的濫用。
產生體驗Token
整合智能體
Web
整合測試代碼
您僅需把安裝代碼添加到網頁的<body>地區中。
<script src="https://g.alicdn.com/apsara-media-aui/amaui-web-aicall/2.5.0/aicall-ui.js"></script>
<script>
new ARTCAICallUI({
userId: '123', // 進入rtc的使用者id,建議使用業務的登入使用者id
root: document.getElementById('root'), // 頁面渲染到的節點,畫面完整填充整個地區
shareToken: 'xxxx', // 從控制台上拷貝的Token
}).render();
</script>Android
下載源碼並整合
源碼下載,請前往GitHub開源專案。
匯入AUIAICall:倉庫代碼下載後,Android Studio菜單選擇:File -> New -> Import Module,匯入選擇檔案夾。
修改檔案夾下的build.gradle的三方庫依賴項。
dependencies { implementation 'androidx.appcompat:appcompat:x.x.x' //修改x.x.x為你工程適配的版本 implementation 'com.google.android.material:material:x.x.x' //修改x.x.x為你工程適配的版本 androidTestImplementation 'androidx.test.espresso:espresso-core:x.x.x' //修改x.x.x為你工程適配的版本 implementation 'com.aliyun.aio:AliVCSDK_ARTC:x.x.x' //修改x.x.x為你工程適配的版本 implementation 'com.aliyun.auikits.android:ARTCAICallKit:x.x.x' implementation 'com.alivc.live.component:PluginAEC:2.0.0' }說明ARTC SDK最新版本:7.9.1;
AICallKit SDK最新版本:2.9.1。
等待gradle同步完成,完成源碼整合。
整合測試代碼
Context currentActivity = AUIAICallEntranceActivity.this;
// 進入rtc的使用者id,建議使用業務的登入使用者id
String loginUserId = "123";
// shareToken是從控制台上拷貝的Token
String shareToken = "xxxxx";
ARTCAICallController.launchCallActivity(currentActivity, shareToken, loginUserId, "");iOS
下載源碼並整合
源碼下載,請前往GitHub開源專案。
匯入AUIAICall:倉庫代碼下載後,拷貝iOS檔案夾到你的APP代碼目錄下,改名為AUIAICall,與您的Podfile檔案在同一層級,可以刪除Example和AICallKit目錄。
修改Podfile,引入:
AliVCSDK_ARTC:適用於即時互動的音視頻終端SDK,也可以使用:AliVCSDK_Standard或AliVCSDK_InteractiveLive,具體整合方式,請參考iOS端。
ARTCAICallKit:AI即時互動通話情境SDK。
AUIFoundation:基礎UI組件。
AUIAICall:AI通話情境UI組件源碼。
#需要iOS11.0及以上才能支援 platform :ios, '11.0' target '你的App target' do # 根據自己的業務情境,整合合適的音視頻終端SDK pod 'AliVCSDK_ARTC', '~> x.x.x' # AI即時互動通話情境SDK pod 'ARTCAICallKit', '~> x.x.x' # 基礎UI組件源碼 pod 'AUIFoundation', :path => "./AUIAICall/AUIBaseKits/AUIFoundation/", :modular_headers => true # AI通話情境UI組件源碼 pod 'AUIAICall', :path => "./AUIAICall/" end說明ARTC SDK最新版本:7.9.1;
AICallKit SDK最新版本:2.9.1。
執行
pod install --repo-update源碼整合完成
整合測試代碼
import AUIFoundation
import AUIAICall
// 下面代碼可以啟動一個智能體通話,可以把下面代碼加入到你的按鈕點擊事件裡
AUIAICallManager.defaultManager.checkDeviceAuth(agentType: .VisionAgent) {
let topVC = viewController ?? UIViewController.av_top()
let controller = AUIAICallStandardController(userId: "123") // userId:進入rtc的使用者id,建議使用業務的登入使用者id
controller.agentShareInfo = "xxxxx" // 從控制台上拷貝的Token
let vc = AUIAICallViewController(controller)
vc.enableVoiceprintSwitch = false
topVC.av_presentFullScreenViewController(vc, animated: true)
}