阿斯特云AI机器人引擎3.0开放平台开发电话营销机器人
2018-03-19 18:23
931 查看
使用阿斯特云的AI机器人引擎编程就简单多了,只写几个函数就可以完成复杂的语音人机交互。
呼叫过程就不写了具体最新文档请阅读open.astyun.com 网站的开发文档。
阿斯特云通讯平台推送我们的应用服务器处理服务模块代码:
推送格式://url示例:http://localhost/?startservice&appid=qw
$ref=$_SERVER['REQUEST_URI'] ; //云通讯回调请求页面的URI
if(strpos($ref,'startservice')){//云通讯IVR启动业务的回调请求
startservice();
}elseif(strpos($ref,'stopservice')){//云通讯IVR结束业务的回调请求
stopservice();
}elseif(strpos($ref,'enterflow')){ //启动业务进入流程
enterflow(); }elseif(strpos($ref,'fangchanmain')){ //房产电话营销流程和AI交互和ASR交互
fangchanmain();
}
//IVR启动业务,在IVR呼入或者IVR外呼后由云通讯平台发起的回调请求
function startservice()
{
//获取参数
$appid = $_REQUEST['appid']; //应用id
$callid = $_REQUEST['callid'];//通话id,由云通讯平台产生的一路通话的唯一标识
$from = $_REQUEST['from'];//主叫号码,当IVR呼入方式为主叫的号码,当IVR外呼的方式则为空
$to = $_REQUEST['to'];//被叫号码,当IVR呼入方式为IVR接入号,当IVR外呼的方式则为外呼的号码
$direction = $_REQUEST['direction']; //呼叫方式,IVR呼入为0,IVR外呼为1
$userdata = $_REQUEST['userdata']; //自定义参数,只有发起当外呼请求中带有才会返回
enterflow();
}
//IVR结束业务,在用户挂机后由云通讯平台发起的回调请求
function stopservice()
{
//获取参数
$appid = $_REQUEST['appid'];//应用id
$callid = $_REQUEST['callid'];//通话id,由云通讯平台产生的一路通话的唯一标识
$starttime = $_REQUEST['starttime']; //主叫通话的开始时间
$endtime = $_REQUEST['endtime']; //主叫通话的结束时间
$callduration = $_REQUEST['callduration'];//主叫通话时长
$sstime = $_REQUEST['sstime']; //被叫通话的开始时间
$setime = $_REQUEST['setime']; //被叫通话的结束时间
$seccallduration = $_REQUEST['seccallduration']; //被叫通话时间
$recordurl = $_REQUEST['recordurl']; //录音文件下载地址
$recordid = $_REQUEST['recordid']; //录音文件Id
$errorcode = $_REQUEST['errorcode']; //通话中异常的错误值
//对云通讯平台回调请求的响应包体,因为不需要后续流程响应空命令
echo "<?xml version='1.0' encoding='UTF-8' ?>
<Response>
<CmdNone/>
</Response>";
}
//通过ai引擎3.0的 api 接口把用户说的话提交给机器人,返回结果指令
//$userId 用户号码 $userInput 用户输入 $aimibot 机器人引擎脚本名称
function get_ai($userId,$userInput,$aimibot)
{
$url="http://demo.astgo.net/ai/api.php?requestType=talk&userId=$userId&userInput=$userInput&aimibot=$aimibot";
$restext = file_get_contents($url);
return $restext;
}
#房产流程
function fangchanmain()
{
$callid = $_REQUEST['callid'];
$message = $_REQUEST['asr_text'];
$asr_recordfile = $_REQUEST['asr_recordfile'];
$arr = explode(";",$message);
$userInput="";
foreach($arr as $val){
$userInput .= substr(strstr($val,"."),1);
}
$data = get_ai($callid,$userInput,'rongsheng');
$arrdata = json_decode($data,true);
$asttext = $arrdata['message'];
$asttext = iconv("UTF-8", "GBK//IGNORE", $asttext);
echo "<?xml version='1.0' encoding='UTF-8'?> \
<Response><PlayAsr tts='true' action='fangchanmain' asr_endkeys='' asr_appid='5a54bbcc' playfilename='$asttext'/>
<Redirect>enterflow</Redirect>
</Response>";
}
#主流程
function enterflow()
{
$maintext = "欢迎进入阿斯特语音AI演示系统,请说 房产进入流程";
$maintext = iconv("UTF-8", "GBK//IGNORE", $maintext);
echo "<?xml version='1.0' encoding='UTF-8'?> \
<Response><PlayAsr action='selectflow' asr_endkeys='' asr_appid='5a54bbcc' playfilename='$maintext' tts='true'/>
<Redirect>enterflow</Redirect></Response>";
}
呼叫过程就不写了具体最新文档请阅读open.astyun.com 网站的开发文档。
阿斯特云通讯平台推送我们的应用服务器处理服务模块代码:
推送格式://url示例:http://localhost/?startservice&appid=qw
$ref=$_SERVER['REQUEST_URI'] ; //云通讯回调请求页面的URI
if(strpos($ref,'startservice')){//云通讯IVR启动业务的回调请求
startservice();
}elseif(strpos($ref,'stopservice')){//云通讯IVR结束业务的回调请求
stopservice();
}elseif(strpos($ref,'enterflow')){ //启动业务进入流程
enterflow(); }elseif(strpos($ref,'fangchanmain')){ //房产电话营销流程和AI交互和ASR交互
fangchanmain();
}
//IVR启动业务,在IVR呼入或者IVR外呼后由云通讯平台发起的回调请求
function startservice()
{
//获取参数
$appid = $_REQUEST['appid']; //应用id
$callid = $_REQUEST['callid'];//通话id,由云通讯平台产生的一路通话的唯一标识
$from = $_REQUEST['from'];//主叫号码,当IVR呼入方式为主叫的号码,当IVR外呼的方式则为空
$to = $_REQUEST['to'];//被叫号码,当IVR呼入方式为IVR接入号,当IVR外呼的方式则为外呼的号码
$direction = $_REQUEST['direction']; //呼叫方式,IVR呼入为0,IVR外呼为1
$userdata = $_REQUEST['userdata']; //自定义参数,只有发起当外呼请求中带有才会返回
enterflow();
}
//IVR结束业务,在用户挂机后由云通讯平台发起的回调请求
function stopservice()
{
//获取参数
$appid = $_REQUEST['appid'];//应用id
$callid = $_REQUEST['callid'];//通话id,由云通讯平台产生的一路通话的唯一标识
$starttime = $_REQUEST['starttime']; //主叫通话的开始时间
$endtime = $_REQUEST['endtime']; //主叫通话的结束时间
$callduration = $_REQUEST['callduration'];//主叫通话时长
$sstime = $_REQUEST['sstime']; //被叫通话的开始时间
$setime = $_REQUEST['setime']; //被叫通话的结束时间
$seccallduration = $_REQUEST['seccallduration']; //被叫通话时间
$recordurl = $_REQUEST['recordurl']; //录音文件下载地址
$recordid = $_REQUEST['recordid']; //录音文件Id
$errorcode = $_REQUEST['errorcode']; //通话中异常的错误值
//对云通讯平台回调请求的响应包体,因为不需要后续流程响应空命令
echo "<?xml version='1.0' encoding='UTF-8' ?>
<Response>
<CmdNone/>
</Response>";
}
//通过ai引擎3.0的 api 接口把用户说的话提交给机器人,返回结果指令
//$userId 用户号码 $userInput 用户输入 $aimibot 机器人引擎脚本名称
function get_ai($userId,$userInput,$aimibot)
{
$url="http://demo.astgo.net/ai/api.php?requestType=talk&userId=$userId&userInput=$userInput&aimibot=$aimibot";
$restext = file_get_contents($url);
return $restext;
}
#房产流程
function fangchanmain()
{
$callid = $_REQUEST['callid'];
$message = $_REQUEST['asr_text'];
$asr_recordfile = $_REQUEST['asr_recordfile'];
$arr = explode(";",$message);
$userInput="";
foreach($arr as $val){
$userInput .= substr(strstr($val,"."),1);
}
$data = get_ai($callid,$userInput,'rongsheng');
$arrdata = json_decode($data,true);
$asttext = $arrdata['message'];
$asttext = iconv("UTF-8", "GBK//IGNORE", $asttext);
echo "<?xml version='1.0' encoding='UTF-8'?> \
<Response><PlayAsr tts='true' action='fangchanmain' asr_endkeys='' asr_appid='5a54bbcc' playfilename='$asttext'/>
<Redirect>enterflow</Redirect>
</Response>";
}
#主流程
function enterflow()
{
$maintext = "欢迎进入阿斯特语音AI演示系统,请说 房产进入流程";
$maintext = iconv("UTF-8", "GBK//IGNORE", $maintext);
echo "<?xml version='1.0' encoding='UTF-8'?> \
<Response><PlayAsr action='selectflow' asr_endkeys='' asr_appid='5a54bbcc' playfilename='$maintext' tts='true'/>
<Redirect>enterflow</Redirect></Response>";
}
相关文章推荐
- 通过语音AI开放平台开发一个语音AI营销机器人
- 一起聊聊:“AI”智能电话营销机器人的产品特征
- 基于讯飞开放平台的安卓语音开发——语音合成(文本→语音)
- 微信开放平台开发(1) 语义理解
- 以 Facebook 的 wit.ai 为例讲解机器人对话平台(Bot Framework)
- 机器人仿真或者开发平台
- 微信开放平台开发——网页微信扫码登录(OAuth2.0)
- 微信开放平台 公众号第三方平台开发 教程三 一键登录授权给第三方平台
- Rop开发手册(2):最简单的服务开放平台框架
- 网易游戏-平台开发工程师-一面(电话面试)
- 基于Android客户端的人人网开放平台开发系列教程
- Symbian多平台游戏引擎开发日记 2006-5-15
- 机器人软件开发平台
- 利用电信能力开放平台轻松开发短信应用
- 中小型机器人开发平台Aopllp的秘密
- 微信开放平台 公众号第三方平台开发 教程五 代公众号发起网页授权源码
- 微信开放平台 公众号第三方平台开发 教程五 代公众号发起网页授权源码
- 微信公众开放平台开发03---百度BAE上搭建属于自己的微信公众平台 -JAVA,微信公众开放平台部署到百度云中BASE2.0,进行调试,木有钱买云服务器的亲们试试
- cynthai原班人马开发的团队协作平台effevo(effevo.com)免费开放了!
- 2、Cocos2dx 3.0游戏开发找小三之引擎简单介绍