本示例介绍了如何调用SmartCall发起智能语音交互通话。

功能介绍

在智能语音交互通话中,支持使用控制台预设的机器人话术,或在每轮通话中通过回调接口返回业务方设置的回应方式。接口SmartCall需要和智能语音交互呼出回调HTTP接口联合使用,语音平台发起呼叫后,会把转换后的语音文本回传给业务方,业务方把下一步的执行动作返回给语音平台。

准备工作

调用API实现智能外呼功能之前,您需要完成以下操作:

代码示例

接口详情请参见SmartCall

如果您需要进行调试请参考使用OpenAPI Explorer
// This file is auto-generated, don't edit it. Thanks.
package com.aliyun:dyvmsapi20170525:*;

import com.aliyun.tea.*;


public class Client {

    public static com.aliyun.dyvmsapi20170525.Client createClient(String accessKeyId, String accessKeySecret, String regionId) throws Exception {
        com.aliyun.tearpc.models.Config config = new com.aliyun.tearpc.models.Config();
        config.accessKeyId = accessKeyId;
        config.accessKeySecret = accessKeySecret;
        config.regionId = regionId;
    }

    public static void main(String[] args) throws Exception {
        com.aliyun.dyvmsapi20170525.Client client = Client.createClient("accessKeyId", "accessKeySecret", "regionId");
        com.aliyun.dyvmsapi20170525.models.SmartCallRequest request = com.aliyun.dyvmsapi20170525.models.SmartCallRequest.build(TeaConverter.buildMap(
            new TeaPair("calledShowNumber", "0633676xx"),
            new TeaPair("calledNumber", "10xx"),
            new TeaPair("voiceCode", "3355eedd-3706-4f75-bff9-e645e88e1730.wav"),
            new TeaPair("pauseTime", 800),
            new TeaPair("muteTime", 10000),
            new TeaPair("actionCodeBreak", false)
        ));
        com.aliyun.dyvmsapi20170525.models.SmartCallResponse response = client.smartCall(request);
    }
}
# This file is auto-generated, don't edit it. Thanks.
from alibabacloud_dyvmsapi20170525.client import Client as DyvmsapiClientClient
from alibabacloud_tea_rpc import models as _rpc_models
from alibabacloud_dyvmsapi20170525 import models as dyvmsapi_client_models


class Client:

    @staticmethod
    def create_client(access_key_id, access_key_secret, region_id):
        """
        使用AK&SK初始化账号Client
        """
        config = _rpc_models.Config(

        )
        config.access_key_id = access_key_id
        config.access_key_secret = access_key_secret
        config.region_id = region_id

    @staticmethod
    def main(args):
        client = create_client("accessKeyId", "accessKeySecret", "regionId")
        request = dyvmsapi_client_models.SmartCallRequest(
            called_show_number="0633676xx",
            called_number="10xx",
            voice_code="3355eedd-3706-4f75-bff9-e645e88e1730.wav",
            pause_time=800,
            mute_time=10000,
            action_code_break=False
        )
        response = client.smart_call(request)
    def __init__(self):
        pass
// This file is auto-generated, don't edit it. Thanks.
package client

import (
  dyvmsapiclient  "github.com/alibabacloud-go/dyvmsapi-20170525/client"
  rpc  "github.com/alibabacloud-go/tea-rpc/client"
  "github.com/alibabacloud-go/tea/tea"
)


// 使用AK&SK初始化账号Client  
func CreateClient (accessKeyId *string, accessKeySecret *string, regionId *string) (_result *dyvmsapiclient.Client) {
  config := &rpc.Config{}
  config.AccessKeyId = accessKeyId
  config.AccessKeySecret = accessKeySecret
  config.RegionId = regionId
  return _result
}

func Main (args []*string) (_err error) {
  client := CreateClient(tea.String("accessKeyId"), tea.String("accessKeySecret"), tea.String("regionId"))
  request := &dyvmsapiclient.SmartCallRequest{
    CalledShowNumber: tea.String("0633676xx"),
    CalledNumber: tea.String("10xx"),
    VoiceCode: tea.String("3355eedd-3706-4f75-bff9-e645e88e1730.wav"),
    PauseTime: tea.Int(800),
    MuteTime: tea.Int(10000),
    ActionCodeBreak: tea.Bool(false),
  }
  response, _err := client.SmartCall(request)
  if _err != nil {
    return _err
  }

  return _err
}
<?php

// This file is auto-generated, don't edit it. Thanks.
namespace alibabacloud/dyvmsapi-20170525:^0\1\0;

use AlibabaCloud\SDK\Dyvmsapi\V20170525\Dyvmsapi;

use AlibabaCloud\Tea\Rpc\Rpc\Config;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\SmartCallRequest;
use AlibabaCloud\SDK\Dyvmsapi\V20170525\Models\SmartCallResponse;

class Client {

    /**
     * 使用AK&SK初始化账号Client
     * @param string $accessKeyId
     * @param string $accessKeySecret
     * @param string $regionId
     * @return Dyvmsapi
     */
    public static function createClient($accessKeyId, $accessKeySecret, $regionId){
        $config = new Config([]);
        $config->accessKeyId = $accessKeyId;
        $config->accessKeySecret = $accessKeySecret;
        $config->regionId = $regionId;
    }

    /**
     * @param array $args
     * @return void
     */
    public static function main($args){
        $client = self::createClient("accessKeyId", "accessKeySecret", "regionId");
        $request = new SmartCallRequest([
            "calledShowNumber" => "0633676xx",
            "calledNumber" => "10xx",
            "voiceCode" => "3355eedd-3706-4f75-bff9-e645e88e1730.wav",
            "pauseTime" => 800,
            "muteTime" => 10000,
            "actionCodeBreak" => false
        ]);
        $response = $client->smartCall($request);
    }
}
// This file is auto-generated, don't edit it. Thanks.

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;


namespace AlibabaCloud.SDK.Dyvmsapi20170525:*
{
    public class Client 
    {

        // 使用AK&SK初始化账号Client  
        public static AlibabaCloud.SDK.Dyvmsapi20170525.Client CreateClient(string accessKeyId, string accessKeySecret, string regionId)
        {
            AlibabaCloud.RPCClient.Models.Config config = new AlibabaCloud.RPCClient.Models.Config();
            config.AccessKeyId = accessKeyId;
            config.AccessKeySecret = accessKeySecret;
            config.RegionId = regionId;
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Dyvmsapi20170525.Client client = Client.CreateClient("accessKeyId", "accessKeySecret", "regionId");
            AlibabaCloud.SDK.Dyvmsapi20170525.Models.SmartCallRequest request = new AlibabaCloud.SDK.Dyvmsapi20170525.Models.SmartCallRequest
            {
                CalledShowNumber = "0633676xx",
                CalledNumber = "10xx",
                VoiceCode = "3355eedd-3706-4f75-bff9-e645e88e1730.wav",
                PauseTime = 800,
                MuteTime = 10000,
                ActionCodeBreak = false,
            };
            AlibabaCloud.SDK.Dyvmsapi20170525.Models.SmartCallResponse response = client.SmartCall(request);
        }


    }
}
// This file is auto-generated, don't edit it
import DyvmsapiClient, * as $DyvmsapiClient from '@alicloud/dyvmsapi20170525';
import RPC, * as $RPC from '@alicloud/rpc-client';
import * as $tea from '@alicloud/tea-typescript';


export default class Client {

  // 使用AK&SK初始化账号Client  
  static createClient(accessKeyId: string, accessKeySecret: string, regionId: string): DyvmsapiClient {
    let config = new $RPC.Config({ });
    config.accessKeyId = accessKeyId;
    config.accessKeySecret = accessKeySecret;
    config.regionId = regionId;
  }

  static async main(args: string[]): Promise<void> {
    let client = Client.createClient("accessKeyId", "accessKeySecret", "regionId");
    let request = new $DyvmsapiClient.SmartCallRequest({
      calledShowNumber: "0633676xx",
      calledNumber: "10xx",
      voiceCode: "3355eedd-3706-4f75-bff9-e645e88e1730.wav",
      pauseTime: 800,
      muteTime: 10000,
      actionCodeBreak: false,
    });
    let response = await client.smartCall(request);
  }

}

执行结果

正常返回结果如下所示:
{
    "Message":"OK",
    "RequestId":"A90E4451-FED7-49D2-87C8-00700A8C4D0D",
    "Code":"OK",
    "CallId":"116012854210^10281427xx"
}

调用SDK返回错误码,详情请参见错误码列表