Todos os produtos
Search
Central de documentação

Intelligent Media Services:Integre um agente com um trecho de código

Última atualização: Jun 28, 2026

Este tópico descreve como testar rapidamente seu agente de IA usando um token de teste gerado no console do Intelligent Media Services (IMS), sem implantar um servidor.

Nota

Esta solução destina-se apenas a testes e não é recomendada para lançamentos oficiais, pois pode resultar no uso indevido do shareToken.

Gere um token de teste

  1. Acesse a página AI Agents e localize o agente que deseja testar. Se não houver agentes disponíveis, crie um antes. Para obter detalhes sobre a criação de agentes, consulte Criar e gerenciar agentes de IA.

  2. Clique em QR Code for Demo na coluna Actions e selecione o período de validade do QR code.

  3. Clique em Generate e salve os QR codes gerados.

    image

Integre o agente de IA

Web

Adicione o código de instalação à seção <body> da página web.

<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

Baixe e integre o source

  1. Acesse o repositório do GitHub para baixar o source.

  2. Importe o AUIAICall: após baixar o source, no Android Studio, navegue até File > New > Import Module e selecione a pasta a ser importada.

  3. Modifique as dependências de bibliotecas de terceiros no arquivo build.gradle.

    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'
    }
    Nota
    • Versão mais recente do SDK ARTC:

    • Versão mais recente do SDK AICallKit: .

  4. Aguarde a conclusão da sincronização.

Execute e teste

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

Baixe e integre o source

  1. Acesse o repositório do GitHub para baixar o source.

  2. Importe o AUIAICall: após baixar o código do repositório, copie a pasta iOS para o diretório de código do seu aplicativo. Renomeie a pasta para AUIAICall e coloque-a no mesmo nível do Podfile. Você pode excluir as pastas Example e AICallKit.

  3. Modifique o Podfile para importar os seguintes componentes:

    • AliVCSDK_ARTC: kit de desenvolvimento de software (SDK) cliente de áudio e vídeo para interação em tempo real. Também é possível usar AliVCSDK_Standard ou AliVCSDK_InteractiveLive. Para mais informações sobre integração, consulte Integrar o SDK para iOS.

    • ARTCAICallKit: SDK para o cenário de chamadas de IA conversacional em tempo real.

    • AUIFoundation: componentes básicos de interface do usuário.

    • AUIAICall: source dos componentes de interface do usuário para o cenário de chamadas de IA.

    # iOS 11.0 or later is required.
    platform :ios, '11.0'
    
    target 'Your app target' do
        # Integrate a suitable audio and video client SDK based on your business scenario. AliVCSDK_ARTC, AliVCSDK_Standard, and AliVCSDK_InteractiveLive are supported.
        pod 'AliVCSDK_ARTC', '~> 7.5.0'
    
        # The SDK for the Real-time Conversational AI call scenario.
        pod 'ARTCAICallKit', '~> 2.8.0'
    
        # The source code of the basic UI components.
        pod 'AUIFoundation', :path => "./AUIAICall/AUIBaseKits/AUIFoundation/", :modular_headers => true
    
        # The source code of the UI components for the AI call scenario.
        pod 'AUIAICall',  :path => "./AUIAICall/"
    end
    Nota
    • Versão mais recente do SDK ARTC:

    • Versão mais recente do SDK AICallKit: .

  4. Execute pod install --repo-update.

  5. A integração do source está concluída.

Execute e teste

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)
}