2.3聊天接口

#### 接口路径:https://dev.lingju.ai/httpapi/ljchat.do <table style="width:100%"> <tbody> <tr height="28" style="font-weight:bold;"> <td height="28" width="130px" >名称</td> <td colspan="3" >聊天接口</td> </tr> <tr height="28" style="font-weight:bold;"> <td height="28" >接口路径</td> <td colspan="3" >https://dev.lingju.ai/httpapi/ljchat.do</td> </tr> <tr height="28" style="font-weight:bold;"> <td height="28" >请求方式</td> <td colspan="3" >post</td> </tr> </tbody> </table> #### http post请求示例: ~~~ post https://dev.lingju.ai/httpapi/ljchat.do json格式串行化post上传,注意请求的header需添加 'Content-Type':'application/json;charset=UTF-8' { "accessToken":"xxxxxxxxxxxxxxxxxxxxxx", "input":"今天天气怎么样", "lat":"23.12635", "lng":"113.38776", "city":"广州", "position":"广东广州", "data":[ { "target":ID, "list":[] } ] } ~~~ #### 请求参数说明: <table style="width:100%"> <thead> <tr height="28"> <th width="130px">参数</th> <th width="100px">数据类型</th> <th width="130px">可需</th> <th colspan="2" >描述</th> </tr> </thead> <tbody> <tr height="23" style="height:17.25pt"> <td height="23" >accessToken</td> <td >String</td> <td>必填</td> <td colspan="2" >分配给开发者的专属appkey,请妥善保管</td> </tr> <tr > <td>input</td> <td>String</td> <td>必填</td> <td colspan="2">文本输入,长度:[1,300],取值:普通标点符号及中英文数字</td> </tr> <tr> <td>city</td> <td>String</td> <td></td> <td colspan="2">城市(该字段如果有参数,必须跟“lat”以及“lng”一起传才有效)</td> </tr> <tr> <td>lat</td> <td>double</td> <td></td> <td colspan="2">纬度</td> </tr> <tr> <td>lng</td> <td>double</td> <td></td> <td colspan="2">经度</td> </tr> <tr> <td>position</td> <td>String</td> <td></td> <td colspan="2">具体位置</td> </tr> <tr> <td rowspan="3">data</td> <td rowspan="3">List</td> <td rowspan="3"></td> <td colspan="2">附带的JSON数据</td> </tr> <tr> <td>target</td> <td>目标对象id,int类型</td> </tr> <tr> <td>list</td> <td>目标对象集合,目标对象数据结构参考<a href="https://api.docs.lingju.ai/doc/43609919/wMpYycjg/cPJW93OK">Chatbot接口指令说明文档</a>中的语义动作目标对象</td> </tr> </tbody> </table> #### 接口返回JSON示例: ~~~ 普通回复: { "answer":"广州今天天气预报说“大雨”,出门最好带上伞。", "status":0 } 带指令的回复: { "answer":"{\"rtext\":\"好的\",\"outc\":0, \"actions\":[{\"action\":\"QUERY\", \"target\":{\"recyle\":0,\"id\":100,\"singer\":[\"周杰伦\"],\"release\":0,\"type\":\"歌曲\"}, \"hints\":{ \"success\":{\"text\":\"好的,为您播放周杰伦的歌\"}, \"failure\":{\"text\":\"抱歉,我找不到周杰伦的歌\"}, \"notsupport\":{\"text\":\"抱歉,我没办法播放歌曲\"} } }, {\"action\":\"SET\", \"target\":{\"id\":300,\"origin\":\"QUERY\",\"control\":\"PLAY\",\"type\":\"AUDIO\"}}]}", "status":0 } ~~~ #### 接口返回说明: ~~~ Content-Type:application/json;charset=UTF-8 ~~~ <table style="width:100%"> <thead> <tr height="28" > <th height="28" width="130px">属性名</th> <th width="100px">数据类型</th> <th>描述</th> </tr> </thead> <tbody> <tr height="23"> <td height="23" >status</td> <td>int</td> <td>状态码,0=成功,其它值则为错误码,请参考错误码表</td> </tr> <tr height="23"> <td height="23" >description</td> <td >String</td> <td>通常为空,出错时会有错误信息</td> </tr> <tr > <td>answer</td> <td >String</td> <td> 取值为字符串,有可能是纯文本内容,也有可能是json格式的字符串。如果是json格式字符串,需自行转换为json对象解析(json对象数据结构请参考<a href="https://api.docs.lingju.ai/doc/43609919/wMpYycjg/cPJW93OK">Chatbot接口指令说明文档</a>)。</td> </tr> </tbody></table>