本章节为您介绍了调用接口SmartCall发起智能语音交互通话的功能介绍和实现方法。
功能介绍
在智能语音交互通话中,支持使用控制台预设的机器人话术,或在每轮通话中通过回调接口返回业务方设置的回应方式。接口SmartCall需要和智能语音交互呼出回调HTTP接口联合使用,语音平台发起呼叫后,会把转换后的语音文本回传给业务方,业务方把下一步的执行动作返回给语音平台。
实现方法
调用API实现智能外呼功能之前,您需要完成以下操作:
- 购买语音号码并审核通过语音模板或语音文件,具体操作请参见快速入门。
- 获取AccessKey信息,详情请参见获取AccessKey。
- 完成本地SDK环境搭建,详情请参见Java SDK。
- 已在服务开通页面开通智能外呼ASR,并在订阅回执消息页面开启智能外呼ASR实时交互。详情请参见回调接口说明和智能外呼回调HTTP接口。
本章节调用接口详情,请参见SmartCall。
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
public class SmartCall {
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>");
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain("dyvmsapi.aliyuncs.com");
request.setVersion("2017-05-25");
request.setAction("SmartCall");
request.putQueryParameter("CalledShowNumber", "0633676xx");
request.putQueryParameter("CalledNumber", "10xx");
request.putQueryParameter("VoiceCode", "3355eedd-3706-4f75-bff9-e645e88e1730.wav");
request.putQueryParameter("PauseTime", "800");
request.putQueryParameter("MuteTime", "10000");
request.putQueryParameter("ActionCodeBreak", "false");
try {
CommonResponse response = client.getCommonResponse(request);
System.out.println(response.getData());
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
e.printStackTrace();
}
}
}
正常返回结果如下所示:
{
"Message":"OK",
"RequestId":"A90E4451-FED7-49D2-87C8-00700A8C4D0D",
"Code":"OK",
"CallId":"116012854210^10281427xx"
}
调用SDK返回错误码,详情请参见错误码列表。
在文档使用中是否遇到以下问题
更多建议
匿名提交