All Products
Search
Document Center

Intelligent Media Services:Integrate an agent by a code snippet

Last Updated:Jan 06, 2026

This topic describes how to quickly test your AI agent by using a trial token generated in the Intelligent Media Services (IMS) console without deploying a server.

Note

This solution is intended for testing purposes only and is not recommended for official release, as it may lead to abuse of shareToken.

Generate a trial token

  1. Go to the AI Agents page and find the agent you want to test. If no agents are available, create one first. For information about how to create an agent, see Create and manage AI agents.

  2. Click QR Code for Demo in the Actions column and select the validity period for the QR code.

  3. Click Generate and save the QR codes generated.

    image

Integrate the AI agent

Web

Add the installation code to the <body> section of the webpage.

<script src="https://g.alicdn.com/apsara-media-aui/amaui-web-aicall/2.5.0/aicall-ui.js"></script>
<script>
  new ARTCAICallUI({
    userId: '123',                          // The user ID that joins communication. The user ID for business system login is recommended.
    root: document.getElementById('root'),  // The node where the UI is rendered. The interface fills the entire area.
    shareToken: 'xxxx',                     // The token copied from the console.
  }).render();
</script>

Android

Download and integrate the source code

  1. Go to the GitHub repository to download the source code.

  2. Import AUIAICall: After you download the source code, go to File > New > Import Module in Android Studio and select the folder to import.

  3. Modify the third-party library dependencies in the build.gradle file.

    dependencies {
        implementation 'androidx.appcompat:appcompat:x.x.x'                     // Change x.x.x to the version compatible with your project
        implementation 'com.google.android.material:material:x.x.x'             // Change x.x.x to the version compatible with your project
        androidTestImplementation 'androidx.test.espresso:espresso-core:x.x.x'  // Change x.x.x to the version compatible with your project
        implementation 'com.aliyun.aio:AliVCSDK_ARTC:x.x.x'                  // Change x.x.x to the version compatible with your project
        implementation 'com.aliyun.auikits.android:ARTCAICallKit:x.x.x'
        implementation 'com.alivc.live.component:PluginAEC:2.0.0'
    }
    Note
    • Latest ARTC SDK version: 7.9.1

    • Latest AICallKit SDK version: 2.9.1.

  4. Wait until the synchronization is complete. 

Run and test

Context currentActivity = AUIAICallEntranceActivity.this;
// The user ID that joins communication. The user ID for business system login is recommended.
String loginUserId = "123";
// The token copied from the console.
String shareToken = "xxxxx";
ARTCAICallController.launchCallActivity(currentActivity, shareToken, loginUserId, "");

iOS

Download and integrate the source code

  1. Go to the GitHub repository to download the source code.

  2. After you download the source code from the repository, copy the iOS folder to the code directory of your app and rename the folder AUIAICall. Make sure that the folder is placed at the same directory level as your Podfile. You can delete the Example and AICallKit directories.

  3. Modify your Podfile to import the following modules:

    • AliVCSDK_ARTC: ApsaraVideo MediaBox SDK for Alibaba Real-Time Communication (ARTC). You can also import AliVCSDK_Standard or AliVCSDK_InteractiveLive. For more information, see iOS.

    • ARTCAICallKit: an SDK for Real-time Conversational AI.

    • AUIFoundation: the basic UI components.

    • AUIAICall: the source code of UI components for Real-time Conversational AI.

    # iOS 11.0 or later is required.
    platform :ios, '11.0'
    
    target' Your app target' do
        # Integrate ApsaraVideo MediaBox SDK based on your business requirements. 
        pod 'AliVCSDK_ARTC', '~> x.x.x'
    
        # An SDK for Real-time Conversational AI.
        pod 'ARTCAICallKit', '~> x.x.x'
    
        # The source code of the basic UI components.
        pod 'AUIFoundation', :path => "./AUIAICall/AUIBaseKits/AUIFoundation/", :modular_headers => true
    
        # The source code of UI components for Real-time Conversational AI.
        pod 'AUIAICall',  :path => "./AUIAICall/"
    end
    Note
    • Latest ARTC SDK version: 7.9.1

    • Latest AICallKit SDK version: 2.9.1.

  4. Run the pod install --repo-update command.

  5. Complete the integration.

Run and test

import AUIFoundation
import AUIAICall

// The following code can initiate a conversation with the agent. You can add the code snippet to your button click event.
AUIAICallManager.defaultManager.checkDeviceAuth(agentType: .VisionAgent) {
    let topVC = viewController ?? UIViewController.av_top()
    let controller = AUIAICallStandardController(userId: "123")   // The user ID that joins communication. The user ID for business system login is recommended.
    controller.agentShareInfo = "xxxxx"   // The token copied from the console.
    let vc = AUIAICallViewController(controller)
    vc.enableVoiceprintSwitch = false
    topVC.av_presentFullScreenViewController(vc, animated: true)
}