机器人技能的webSocket接入文档
机器人技能介绍
机器人技能是图灵基于自然语言处理技术,开发的一系列有趣实用的能力,如歌曲点播、诗词背诵、天气查询等
接口Demo
部分接口demo如下:
java语言demo参考
集成websocket请求时,需按照以下要求:
| 内容 | 说明 |
|---|---|
| 传输方式 | ws[s] (若对数据通信有较高的安全要求,建议选择wss接入方式来访问图灵服务,由于ssl层验证预计会额外多花费40\~50ms的时间。) |
| 请求地址 | ws[s]://ws-api.turingapi.com/api/v2 |
| 字符编码 | UTF-8 |
| 响应格式 | json |
| 文本语言 | 中文 |
| 支持机器人类型 | SDK接入(Android)、WebSocket接入、混合SDK接入(Android)、混合SDK接入(Linux) |
| 是否支持并发 | SOCKET不允许并发请求,即上一轮请求未完成(result-done)时不允许发送下一个请求。 |
数据加密方式
加密说明
API接口默认不加密(Biz平台可选择加密状态),为保证接口的安全性和稳定性,可对接口数据进行加密;
- AES加密方式详见:
加密模式 CBC
填充 PKCS5Padding
数据块 128位(密钥为16位)
输出 base64编码字符串
编码 utf-8
密钥 apikey+图灵官网机器人详情页Secret+当前毫秒时间戳(取输入参数)-->对该字符串取16位小写md5值
(参考 https://www.sojson.com/encrypt_md5.html)
注:偏移量字符串等于密钥
加密参考页面 http://tool.chacuo.net/cryptaes
- 加密后主要代码:
String data="加密前内容";
//加密方法
data=AesUtils.getTlAes(apiKey, apiSecret, time).encrypt(data);
- 加密后请求示例如下:
{
"data":"加密后的内容",
"key":"ed474dae62*********67050faea1788",
"timestamp":"150******7793"
}
请求参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| key | String | Y | biz平台设置机器人的apiKey |
| timestamp | String | Y | 时间戳 |
| data | JSON | Y | 配置信息,参考下方参数data字段说明 |
data字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| deviceId | String | Y | 用户设备id. 要求:1,长度小于等于32位。 2,需由字母或数字组成,其他字符可能导致部分功能错误 |
| requestType | Array | Y | nlp需要请求的内容固定应该为[1] |
| nlpRequest | Json | Y | nlp内容请求信息,参考下方参数nlpRequest字段说明 |
data - nlpRequest字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| content | json | Y | 输入信息,参考下方参数nlpRequest - content字段说 |
| clientInfo | json | N | 客户端状态 ,参考下方 nlpRequest - clientInfo 字段说明 |
| userInfo | json | N | 用户参数,参考下方 nlpRequest - userInfo 字段说明 |
nlpRequest - content 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| type | int | N | 输入类型,固定值为0,不传默认也是0 |
| data | String | Y | 输入文本类型的内容 |
nlpRequest - userInfo 字段说明
| 参数 | 类型 | 是否必须 | 取值范围 | 说明 |
|---|---|---|---|---|
| requestIP | String | N | 客户端ip地址 | 可上传客户端ip地址 |
| useCodes | Array | N | 应用code | 用户此次交互仅使用该参数中的应用, |
nlpRequest - clientInfo 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| appState | json | N | 客户端状态,开启此字段可以直接进入此技能,关闭同理,参考下方clientInfo - appState 字段说明 |
| robotSkill | json | N | 针对应用code的自定义参数,参考下方 clientInfo - robotSkill 字段说明 |
clientInfo - appState 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| code | int | Y | 应用code |
| operateState | int | Y | 请求应用时的状态值(与输出的operateState无关) |
clientInfo - robotSkill 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| key | String | N | 应用code |
| value | JSON | N | key应用使用的自定义参数 |
简单nlp输入示例:
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "你叫什么名字"
}
]
}
}
}
上方对应的返回示例:
{
"code":200,
"done":true,
"globalId":"219535051255500001",
"message":"success",
"nlpResponse":{
"intent":{
"code":100000,
"operateState":1010
},
"results":[
{
"groupType":0,
"resultType":"text",
"values":{
"emotionId":10200,
"sentenceId":0,
"text":"我的名字叫图灵机器人,认识你很高兴呢!"
}
}
]
}
}
返回参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| globalId | String | Y | 请求唯一标识,用于图灵排查日志 |
| code | int | Y | 状态code;参考状态code列表 |
| nlpResponse | json | N | 输出结果集,详细查看下方nlpResponse 参数说明 |
| done | boolean | Y | |
| message | String | Y | ode对应的说明;参考状态code列表 |
nlpResponse参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| intent | Intent | Y | 请求意图,详细参考下方 nlpResponse - Intent 参数说明 |
| results | Array | N | 输出结果集,详细参考nlpResponse - results 字段说明 |
nlpResponse - Intent 参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| code | int | Y | 输出技能code,详细参数intent - code 字段说明 |
| operateState | int | Y | 技能状态(每个技能单独定义) |
| intentName | String | N | 意图名称 |
| actionName | String | N | 意图动作名称 |
| parameters | Map | N | 应用参数 |
intent - code 字段说明
| code | 说明 |
|---|---|
| 100000 | 儿童聊天 |
| 100302 | 知识库 |
| 200205 | 十万个为什么 |
| 200209 | 维基百科 |
| 200301 | 动物叫声 |
| 200302 | 大自然声音 |
| 200303 | 乐器声音 |
| 1000732 | 单位换算 |
| 200101 | 歌曲点播 |
| 200702 | 日期查询 |
| 200702 | 时间查询 |
| 200201 | 故事点播 |
| 200401 | 诗词背诵 |
| 201401 | 天气查询 |
| 201711 | 中英互译 |
| 200710 | 闹钟 |
| 900110 | 电量查询 |
| 900101 | 休眠 |
| 900110 | 屏幕亮度 |
| 200701 | 跳舞 |
| 201601 | 打开应用 |
Intent - operateState 字段说明
| 通用operateState | 说明 |
|---|---|
| 1000 | 主动退出 |
| 1010 | 无上下文结束 |
| 1100 | 启动 |
| 1200 | 暂停 |
| 1300 | 继续 |
| 1400 | 等待重启 |
补充说明:
- operateState为技能意图,存在扩展性,可能后续会有新增。
- 每个技能会输出单独定义operateState,可在技能说明中,对应技能查看operateState
nlpResponse - results 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| resultType | String | Y | 输出类型 文本(text) 链接(url) 音频(voice) 视频(video) 图片(image) 图文(news) 动作表情(action) |
| values | Map | Y | 输出内容(必包含key等于resultType的值) |
| groupType | int | Y | 组类型(普通接入可忽略该参数) 0为独立输出; 大于0时可能包含同组相关内容 |
附录
状态code列表
| code | 说明 |
|---|---|
| 200 | 正确结果返回 |
| 220 | 参数上传完成,正在请求nlp |
| 230 | ASR/NLP正确处理,但tts功能处理失败(单独请求TTS功能,异常时也返回该code) |
| 240 | 输入参数为空,nlp不处理 |
| 300 | 无效数据:二进制参数已完成传输,不要发送该数据 |
| 4004 | 机器人类型非法 |
| 4005 | apikey信息错误 |
| 4006 | deviceId信息错误 |
| 4007 | 解密失败,您的加密逻辑存在异常 |
| 4008 | 数据内容格式错误 |
| 4009 | 机器人被禁用 |
| 4010 | 试用期已过 |
| 4012 | 今天我们已经聊了很多啦,明天再来找我聊天吧。 |
| 4013 | 这一小时的对话次数已经超过我的极限啦,让我休息一下,待会再聊 |
| 4014 | 这一分钟里我们已经聊了很多啦,休息,休息一下吧 |
| 4016 | 单次交互时间过长,请查看文档! |
| 4025 | 上传数据失败,请稍后\~ |
| 4026 | nlp请求内容超过150字符,内容过长不支持 |
| 4027 | 请求类型不能为空 |
| 4030 | NLP调用次数耗尽 |
| 4100 | 服务正在升级 请稍后再试 |
| 4101 | 请求没有正确初始化! |
| 4102 | 长时间未请求业务,关闭连接 |
| 4200 | robot信息异常 |
| 4201 | nlp处理异常 |
注意
- 4XXX\~5XXX异常,服务端将主动关闭与客户端的connection,其余code不会关闭;
TuringOs技能说明
聊天对话
知识库(100302)
1,介绍
基于图灵的NLU能力,精准命中用户预编写的问答对。支持相似问法扩展,并且支持通过对action、emotion的参数扩展(暂时只支持数字),来实现动作控制和表情控制。
2,使用方式
2-1.在【“Biz开放平台” - “机器人功能” - “知识库”】模块中点击“新增问题”,添加问题及答案;
2-2.选中答案文本,点击“添加表情和动作”,填写对应值;
2-3.当与机器人进行交互且命中预设问题时,将返回设置的动作及表情值,以便设备端进行相应处理;
3,输入输出示例
输入:你好呀
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "你好呀"
}
]
}
}
}
对应的输出:
{
"code": 200,
"done": true,
"globalId": "219601441655500001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 100302,
"operateState": 1010
},
"results": [{
"groupType": 1,
"resultType": "text",
"values": {
"emotionId": 10300,
"text": "你的嘴真甜呢"
}
}, {
"groupType": 2,
"resultType": "action",
"values": {
"action": {
"emotion": "2",
"action": "3"
}
}
}]
}
}
儿童聊天(100000)
1,介绍
儿童聊天基于图灵亿万级别的儿童语料库,回答活泼自然且正能量,在用户与机器人闲聊时,用户询问机器人一句话,机器人会通过对话语的理解返回相应的回答,并且回答符合儿童的聊天交互,语言温和恰当。
图灵在儿童聊天上提供了对交互用户的基本信息的记忆功能,信息会记录在图灵云端,丰富交互的乐趣。目前的记忆能力包括对姓名、年龄、性别、星座的记忆。重复告知机器人信息,第二次会覆盖第一次的信息。
2,普通输入输出示例:
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "我们做朋友吧"
}
]
}
}
}
对应的输出:
{
"code": 200,
"done": true,
"globalId": "219597691997390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 100000,
"operateState": 1010
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"emotionId": 10900,
"sentenceId": 0,
"text": "好啊,谢谢小主人愿意跟我做朋友,如果你愿意陪我一起玩呐,你就是我最最最最好的朋友,嘻嘻。"
}
}]
}
}
3,带有上下文的输入示例
3-1 输入:我是小肖
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "我是小肖"
}
]
}
}
}
对应的输出:
{
"code": 200,
"done": true,
"globalId": "219598226493500001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 100000,
"operateState": 1010
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"emotionId": 10300,
"sentenceId": 0,
"text": "那人家以后就叫你小肖喽~"
}
}]
}
}
3-2 输入:我是谁
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "我是谁"
}
]
}
}
}
对应的输出:
{
"code": 200,
"done": true,
"globalId": "219598241140390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 100000,
"operateState": 1010
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"emotionId": 0,
"sentenceId": 0,
"text": "你是我的小肖啊~"
}
}]
}
}
十万个为什么(200205)
1,介绍
基于图灵的知识图谱与专属教育知识库构建的十万个为什么问答。
2,输入输出示例
输入:人为什么要喝水?
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "人为什么要喝水"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219611513295390003",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200205,
"operateState": 1010
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "水是人类最必需的营养素之一,是吸收营养、输送营养物质的介质,又是排泄废物的载体,人通过水在体内的循环完成新陈代谢过程。在这个过程中水还具有人体散热,调节体温等作用,它对人类生命至关重要,所以人要喝水。"
}
}]
}
}
维基百科(200209)
1,介绍
维基百科是图灵基于自身知识库,并结合维基百科的适合百科内容,搭建的百科问答能力。
2,输入输出示例
输入:北京简介
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "北京简介"
}
]
}
}
}
对应输出:
{
"code": 200,
"done": true,
"globalId": "219611718653390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200209,
"intentName": "wiki",
"operateState": 1010,
"parameters": {
"wiki_keyword": "北京"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "北京简称京,是中华人民共和国首都,是直辖市,国家中心城市,是全国政治中心,文化中心,国际交往中心,科技创新中心,是中国共产党中央委员会,中华人民共和国中央人民政府和全国人民代表大会的办公所在地。"
}
}]
}
}
趣味应用
单位==换算(新)(1000732)==
1,介绍
说法示例
1,1米是多少厘米
2,输入输出示例
普通输入:
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"10华氏度等于多少摄氏度"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219629988619500001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000732,
"operateState": 1010,
"parameters": {
"unitDest": "摄氏度",
"approximate": true,
"unitSrc": "华氏度",
"numberSrc": "10"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "10华氏度约等于-12.2222222222摄氏度"
}
}]
}
}
指定技能,并且开启进入技能输入:
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "10华氏度等于多少摄氏度?"
}
],
"userInfo":{
"useCodes":[1000732]
},
"clientInfo":{
"appState":{
"code":1000732,
"operateState":1100
}
}
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219630091144390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 1000732,
"operateState": 1010,
"parameters": {
"unitDest": "摄氏度",
"approximate": true,
"unitSrc": "华氏度",
"numberSrc": "10"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "10华氏度约等于-12.2222222222摄氏度"
}
}]
}
}
动物叫声(200301)
1,介绍
动物叫声是模仿动物叫声的一个趣味小应用。
说法示例
1,狗的叫声
2,猫的叫声
2,输入输出
普通输入:狗的叫声
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "狗的叫声"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219613889884390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200301,
"intentName": "animal_sounds",
"operateState": 1010,
"parameters": {
"english": "dog",
"name": "狗",
"animalName": "狗"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "请听狗的声音。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://iot-cdn.turingapi.com/202310201635/988d6c32677db8d49b7572a2031f9601/media/audio/2018-10-16/de27ffec-d50f-414b-9a06-ac0e282881ad.mp3"
}
}]
}
}
指定技能输入:
{
"key": "c1b7685c744941f392067716bc318aed",
"timestamp": "1585799006000",
"data": {
"deviceId": "111111",
"requestType": [
1
],
"nlpRequest": {
"content": [
{
"data": "狗的叫声"
}
],
"userInfo":{
"useCodes":[200301]
},
"clientInfo":{
"appState":{
"code":200301,
"operateState":1100
}
}
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219613972671390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200301,
"intentName": "animal_sounds",
"operateState": 1010,
"parameters": {
"english": "dog",
"name": "狗",
"animalName": "狗"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "请听狗的声音。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://iot-cdn.turingapi.com/202310201636/38960d790d558f7b6d6723638accc41e/media/audio/2018-10-16/de27ffec-d50f-414b-9a06-ac0e282881ad.mp3"
}
}]
}
}
大自然声音(200302)
1,介绍
大自然声音是机器人模仿大自然的声音的一个趣味小应用。
说法示例
1,下雨的声音
2,打雷的声音
2,输入输出
输入:下雨的声音
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"下雨的声音"
}
]
}
}
}
输出
{
"code": 200,
"done": true,
"globalId": "219619890942500001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200302,
"intentName": "natural_sounds",
"operateState": 1010,
"parameters": {
"name": "雨",
"resourcesName": "雨"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "请听雨的声音。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://iot-cdn.turingapi.com/202310201815/d577b23c34a6967763f478325fb29955/media/audio/20180524/2229c502f8794cb492eb560205eab70b.mp3"
}
}]
}
}
乐器声音(200303)
1,介绍
乐器声音是机器人模仿乐器的声音的一个趣味小技能。
2,输入输出
输入:钢琴的声音
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"钢琴的声音"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219619990025390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200303,
"intentName": "music_instrument",
"operateState": 1010,
"parameters": {
"name": "钢琴",
"resourcesName": "钢琴"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "请听钢琴的声音。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://iot-cdn.turingapi.com/202310201817/58a67fd792e369939e3dbf9683350dd0/media/audio/3a691b281af311e99fd860f6774f01f9.mp3"
}
}]
}
}
实用功能
歌曲点播(200101)
1,介绍
歌曲点播是图灵提供的一套歌曲播放的能力。
说法示例
| 点播指令 | 示例 |
|---|---|
| 随机播歌 | 我想听歌、唱首歌 |
| 多轮操作 | 唱首歌、下一首、上一首、单曲循环、暂停播放、继续播放、停止 |
2,输入输出
输入随机播歌指令:唱首歌
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"唱首歌"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219620311562390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200101,
"intentName": "play_music",
"operateState": 1100,
"parameters": {
"singer": "宝宝儿歌故事哄睡大全",
"name": "大头儿子和小头爸爸"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "好的,请听我唱宝宝儿歌故事哄睡大全的“大头儿子和小头爸爸”。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://lu.sycdn.kuwo.cn/97484d698f1ff401e1f6525349f27202/653235bc/resource/n3/79/39/2417339019.mp3"
}
}]
}
}
输入多轮操作的指令:下一首
{
"code": 200,
"done": true,
"globalId": "219620357069390003",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200101,
"intentName": "play_control",
"operateState": 2006,
"parameters": {
"singer": "馅儿",
"name": "预谋 + 太多(Live)"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "好的,我要唱下一首了。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://er.sycdn.kuwo.cn/2198aa5fd8f68eac14412a08b02f9833/653238f0/resource/30106/trackmedia/M500002BTlC00PRtRZ.mp3"
}
}]
}
}
从聊天直接切换到唱歌指令:先输入你好,然后输入下一首,如果想要进入到歌曲点播环节,需开启歌曲点播
输入:{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"下一首"
}
],
"userInfo":{
"useCodes":[
200101
]
},
"clientInfo":{
"appState":{
"code":200101,
"operateState":1100
}
}
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219620677320390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200101,
"intentName": "play_control",
"operateState": 2006,
"parameters": {
"singer": "陈粒",
"name": "桥豆麻袋"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "好的,我要唱下一首了。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://other.player.rh01.sycdn.kuwo.cn/e09c2bc1f99b160d9bd9345500428486/65323a31/resource/n1/36/72/595432021.mp3"
}
}]
}
}
3,返回参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| singer | String | N | 歌手名 |
| name | String | N | 歌曲名 |
4,operateState字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| operateState | int | Y | 1100:开始 1101:无解析内容的开始(如:唱首歌) 2002:停止 1200:暂停 1300:继续 2005:上一首 2006:下一首 3001:随机播放 3002:单曲循环 3003:列表循环 |
故事点播(200201)
1,介绍
故事点播是图灵提供的一套故事播放的能力。
说法示例
| 点播指令 | 示例 |
|---|---|
| 随机点播 | 我想听故事、讲个故事 |
| 多轮操作 | 讲个故事、下一个、上一个、单曲循环、暂停、继续、停止 |
2,输入输出
输入:我想听故事
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"我想听故事"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219620810300390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200201,
"intentName": "play_story",
"operateState": 1100,
"parameters": {
"author": "落叶无声",
"name": "简介"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "好的,请听我讲落叶无声的“简介”。"
}
}, {
"groupType": 0,
"resultType": "voice",
"values": {
"voice": "http://lv.sycdn.kuwo.cn/144301ea978bb7a9cf00bab09dafb089/65323ab6/resource/30106/trackmedia/long/M500004dJWoN0GKm08.mp3"
}
}]
}
}
3,返回参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| author | String | N | 作者 |
| name | String | N | 故事名 |
4,operateState字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| operateState | int | Y | 1100:开始 1101:无解析内容的开始(如:唱首歌) 2002:停止 1200:暂停 1300:继续 2005:上一首 2006:下一首 3001:随机播放 3002:单曲循环 3003:列表循环 |
诗词背诵(200401)
1,介绍
诗词背诵是图灵提供的一套诗词学习能力,可以让机器人背诵各朝各代的诗词,可以询问诗词的作者、诗词的上下句等。当诗词有音频资源(即朗诵版)时,图灵会优先返回音频资源的朗读,如果没有则会返回诗词的文字。
说法示例
| 指令 | 示例 |
|---|---|
| 背诵诗词 | 背诵静夜思 |
| 询问作者 | 登鹳雀楼的作者是谁 |
| 类型背诵 | 背诵一首唐诗 |
| 作者点播 | 背诵杜甫的诗 |
| 询问上下句 | 举头望明月的上一句是什么 |
2,输入输出
输入:背诵静夜思
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"背诵静夜思"
}
],
"userInfo":{
"useCodes":[
200401
]
},
"clientInfo":{
"appState":{
"code":200401,
"operateState":1100
}
}
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219621122281500001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200401,
"intentName": "read",
"operateState": 1100,
"parameters": {
"author": "李白",
"name": "静夜思",
"type": "诗",
"years": "唐代",
"content": "床前明月光,疑是地上霜。举头望明月,低头思故乡。"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "静夜思 唐代 李白 床前明月光,疑是地上霜。举头望明月,低头思故乡。"
}
}]
}
}
3,返回参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| years | String | N | 年代 |
| author | String | N | 作者 |
| name | String | N | 诗名 |
| type | String | N | 诗词类型 |
| content | String | N | 诗词内容 |
4,1operateState 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| operateState | String | N | 1100:开始 1101:无解析内容的开始(如:诗词背诵) 2005:上一首 2006:下一首 |
天气查询(201401)
1,介绍
天气查询是图灵提供的一套天气查询能力,可以查询国内各地区的天气,并且可以查询今天、明天、后天等时间的天气,且具有上下文的能力。
2,天气查询的逻辑:
没有使用extra扩展参数请求时:当没有携带相应城市名称信息时,会反问用户在哪个城市,收到城市名称后,会报出当前天气。
当使用了extra扩展参数请求时:支持在每次请求时携带含有城市名、GPS经纬度、IP的相关信息。这时询问天气时,如果请求是“北京天气如何”,会返回北京的天气信息,如果请求是“今天天气怎么样”,会按照extra扩展参数中上传的信息返回相应天气信息。当请求中携带了上述信息时,会按照如下优先级查询天气:请求中携带地址>城市名>经纬度>IP。
说法示例
携带城市名称信息:
1. 深圳天气怎么样
2. 明天深圳天气怎么样
未携带城市名称信息:
a. 上海今天天气怎么样
b. 深圳
c. 明天
3,返回示例(携带城市名称信息)
- 深圳天气怎么样
{
"globalId": "121940474338510138",
"intent": {
"code": 201401,
"intentName": "ask_weather",
"operateState": 1010,
"parameters": {
"date": "2020-05-12",
"city": "深圳市",
"weather": {
"date": "2020-05-12",
"pm25": 17,
"nowTemp": "28℃",
"weatherDetails": [
{
"date": "周二",
"maxTemperature": 29,
"minTemperature": 23,
"temperature": "29 ~ 23℃",
"weather": "雷阵雨",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周三",
"maxTemperature": 30,
"minTemperature": 25,
"temperature": "30 ~ 25℃",
"weather": "小雨",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周四",
"maxTemperature": 30,
"minTemperature": 25,
"temperature": "30 ~ 25℃",
"weather": "多云",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周五",
"maxTemperature": 32,
"minTemperature": 26,
"temperature": "32 ~ 26℃",
"weather": "多云",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周六",
"maxTemperature": 33,
"minTemperature": 27,
"temperature": "33 ~ 27℃",
"weather": "多云转阵雨",
"maxWind": 1,
"wind": "持续无风向微风"
}
],
"currentCity": "深圳市",
"weatherServices": [
{
"des": "天气热,建议着短裙、短裤、短薄外套、T恤等夏季服装。",
"level": "热",
"title": "穿衣指数"
},
{
"des": "不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。",
"level": "不宜",
"title": "洗车指数"
},
{
"des": "有降水,推荐您在室内进行健身休闲运动;若坚持户外运动,须注意携带雨具并注意避雨防滑。",
"level": "较不宜",
"title": "运动指数"
},
{
"des": "相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。",
"level": "较易发",
"title": "感冒指数"
}
]
}
}
},
"results": [
{
"groupType": 0,
"resultType": "text",
"values": {
"text": "深圳市今天雷阵雨,23到29摄氏度,持续无风向微风。PM2.5指数17。天气热,建议着短裙、短裤、短薄外套、T恤等夏季服装。"
}
}
]
}
4,返回示例(未携带城市名称信息)
- 今天天气怎么样
{
"globalId": "121940479998010315",
"intent": {
"code": 201401,
"intentName": "ask_weather",
"operateState": 1101,
"parameters": {}
},
"results": [
{
"groupType": 0,
"resultType": "text",
"values": {
"text": "请告诉我你在哪个城市。"
}
}
]
}
- 深圳
{
"globalId": "111940481829510110",
"intent": {
"code": 201401,
"intentName": "location",
"operateState": 1010,
"parameters": {
"date": "2020-05-12",
"city": "深圳市",
"weather": {
"date": "2020-05-12",
"pm25": 17,
"nowTemp": "28℃",
"weatherDetails": [
{
"date": "周二",
"maxTemperature": 29,
"minTemperature": 23,
"temperature": "29 ~ 23℃",
"weather": "雷阵雨",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周三",
"maxTemperature": 30,
"minTemperature": 25,
"temperature": "30 ~ 25℃",
"weather": "小雨",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周四",
"maxTemperature": 30,
"minTemperature": 25,
"temperature": "30 ~ 25℃",
"weather": "多云",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周五",
"maxTemperature": 32,
"minTemperature": 26,
"temperature": "32 ~ 26℃",
"weather": "多云",
"maxWind": 1,
"wind": "持续无风向微风"
},
{
"date": "周六",
"maxTemperature": 33,
"minTemperature": 27,
"temperature": "33 ~ 27℃",
"weather": "多云转阵雨",
"maxWind": 1,
"wind": "持续无风向微风"
}
],
"currentCity": "深圳市",
"weatherServices": [
{
"des": "天气热,建议着短裙、短裤、短薄外套、T恤等夏季服装。",
"level": "热",
"title": "穿衣指数"
},
{
"des": "不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。",
"level": "不宜",
"title": "洗车指数"
},
{
"des": "有降水,推荐您在室内进行健身休闲运动;若坚持户外运动,须注意携带雨具并注意避雨防滑。",
"level": "较不宜",
"title": "运动指数"
},
{
"des": "相对今天出现了较大幅度降温,较易发生感冒,体质较弱的朋友请注意适当防护。",
"level": "较易发",
"title": "感冒指数"
}
]
}
}
},
"results": [
{
"groupType": 0,
"resultType": "text",
"values": {
"text": "深圳市今天雷阵雨,23到29摄氏度,持续无风向微风。PM2.5指数17。天气热,建议着短裙、短裤、短薄外套、T恤等夏季服装。"
}
}
]
}
5,socket请求中利用扩展参数请求
userInfo 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| requestIp | String | N | 请求ip |
location 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| city | String | N | 城市名 |
| longitude | String | N | 经度 |
| latitude | String | N | 维度 |
带extra扩展参数请求示例
- 今天天气怎么样
输入:
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"2222",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"今天天气怎么样"
}
],
"userInfo":{
"requestIP":"58.250.250.202"
},
"location": {
"city": "深圳",
"longitude": "113.9567842900",
"latitude": "22.5381904200"
}
}
}
}
返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| date | String | 时间(yyyy-MM-dd) |
| city | String | 城市 |
| weather | Weather | 天气信息,详细参考Weather字段说明 |
Weather 字段说明
| 字段名称 | 字段类型 | 字段说明 |
|---|---|---|
| currentCity | String | 当前城市 |
| date | String | 当前日期 |
| nowTemp | String | 现在温度 |
| pm25 | int | PM2.5指数 |
| weatherDetails | Array | 一周天气信息,详细参考WeatherDetail字段说明 |
| weatherServices | Array | 查询日期的穿衣指数、洗车指数、感冒指数、运动指数,详细参考WeatherService字段说明 |
WeatherDetail 字段说明
| 字段名称 | 字段类型 | 字段说明 |
|---|---|---|
| date | String | 星期 |
| maxTemperature | int | 最高温度 |
| minTemperature | int | 最低温度 |
| maxWind | int | 最大风力 |
| temperature | String | 温度区间 |
| weather | String | 天气 |
| wind | String | 风向和风力 |
WeatherService 字段说明
| 字段名称 | 字段类型 | 字段说明 |
|---|---|---|
| des | String | 指数描述 |
| level | String | 指数等级 |
| title | String | 指数名称 |
operateState 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| operateState | String | N | 1101:查询地址 1010/1010:天气信息输出 |
日期查询(200702)
1,介绍
日期查询是图灵提供的一套查询日期的能力,包括对日期的查询、对阳历阴历的查询、对节日的查询、对星期的查询。
说法示例
| 指令 | 示例 |
|---|---|
| 查询日期 | 今天是几号 |
| 查询星期 | 今天是周几 |
| 查询节日 | 端午节是哪一天 |
| 查询阴历 | 八月二十五日的阴历 |
2,输入输出
输入:
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"今天是几号"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219622036114500001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200702,
"intentName": "date_query",
"operateState": 1010,
"parameters": {
"currentTime": 1697791871857,
"dateType": "date"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "今天是2023年10月20日。"
}
}]
}
}
中英互译(201711)
1,介绍
中英互译是图灵提供的机器翻译能力,可以进行中译英和英译中。
说法示例
1. 苹果用英语怎么说
2. 把我喜欢你翻译成英语
3. apple是什么意思
4. 把orange翻译成中文
2,输入输出
输入:
{
"key":"c1b7685c744941f392067716bc318aed",
"timestamp":"1585799006000",
"data":{
"deviceId":"111111",
"requestType":[
1
],
"nlpRequest":{
"content":[
{
"data":"苹果用英语怎么说"
}
]
}
}
}
输出:
{
"code": 200,
"done": true,
"globalId": "219622122052390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 201711,
"intentName": "translate",
"operateState": 1010,
"parameters": {
"originalText": "苹果",
"translation": "apple",
"model": "Chinese2English"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "苹果翻译成英文是:apple"
}
}]
}
}
时间查询(200702)
1,介绍
时间查询是图灵提供的查询时间的功能,可以查询现在的北京时间。
说法示例
1. 现在是几点
2. 几点了
2,输入输出
输入:现在是几点
输出:
{
"code": 200,
"done": true,
"globalId": "219622198821390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200702,
"intentName": "time",
"operateState": 1010,
"parameters": {
"currentTime": 1697792034564,
"dateType": "time"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "现在时间是2023年10月20日16点53分。"
}
}]
}
}
设备控制
闹钟(200710)
1,介绍
闹钟是图灵提供的闹钟定制功能,可以解析设定闹钟的语句并返回需要设定的闹钟的时间、事件等参数给前端,前端通过返回的参数去进行闹钟的记忆和设置。
说法示例
1. 十分钟后叫我
2. 下午三点叫我起床
3. 每天下午三点叫我起床
4. 每周三下午三点叫我起床
5. 下午六点提醒我吃饭
2,输入输出
输入: 十分钟后叫我
输出:
{
"code": 200,
"done": true,
"globalId": "219622299470500001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200710,
"intentName": "alarm",
"operateState": 1010,
"parameters": {
"cycleType": 0,
"alarmType": "remind",
"endDate": "2023-10-20",
"timeLen": "600",
"action": "add",
"alarmTag": "alarmClock",
"time": "17:05:35",
"startDate": "2023-10-20"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "好的,我会在10月20日的17点5分提醒你的。"
}
}]
}
}
电量查询(900110)
1,介绍
用户可根据返回的code值进行电量的相关处理。
说法示例
1. 查询电量、电量查询
2,输入输出
输入:电量查询
输出:
{
"code": 200,
"done": true,
"globalId": "219622404633390003",
"message": "success",
"nlpResponse": {
"intent": {
"code": 900110,
"intentName": "battery",
"operateState": 11030
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "好的。"
}
}]
}
}
休眠(900101)
1,介绍
休眠指令是图灵提供给用户的控制指令,图灵解析用户的语言并返回休眠指令给前端做处理。
说法示例
1. 睡觉吧
2. 再见
3. 拜拜
2,输入输出
输入:再见
输出:
{
"code": 200,
"done": true,
"globalId": "219622472136390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 900101,
"intentName": "sleep",
"operateState": 1000,
"parameters": {
"action": "sleep"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "再见,我会想你的。"
}
}]
}
}
屏幕亮度(900110)
1,介绍
屏幕亮度技能主要是对屏幕亮度进行控制。
说法示例
1. 屏幕亮点、屏幕暗点
2. 增大屏幕亮度、减小屏幕亮度
3. 调高屏幕亮度、调低屏幕亮度
4. 屏幕调到最亮、屏幕调到最暗
5. 屏幕调亮、屏幕调暗
6. 屏幕太亮了、屏幕太暗了
2,输入输出
输入: 屏幕亮点
输出:
{
"code": 200,
"done": true,
"globalId": "219622543382390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 900110,
"intentName": "brightness",
"operateState": 11021,
"parameters": {
"setting_level": 1,
"type": "up"
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "好的"
}
}]
}
}
3,返回参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| operateState | int | Y | 11021:增大屏幕亮度/最亮/太暗了 11022:减小屏幕亮度/最暗/太亮了 |
| type | String | N | 屏幕调节类型: up:增大亮度/需要增加亮度(太暗了) down:减小亮度/需要减小亮度(太亮了) max:调到最亮 min:调到最暗 |
| setting_level | String | N | 操作命令字段,此处表示亮度值: 固定为1 |
跳舞(200701)
1,介绍
模拟跳舞的一个小技能。
说法示例
1. 跳舞、跳个舞、跳个舞吧
2,输入输出
输入:跳舞
输出:
{
"code": 200,
"done": true,
"globalId": "219622642167500002",
"message": "success",
"nlpResponse": {
"intent": {
"code": 200701,
"intentName": "dance",
"operateState": 11000,
"parameters": {
"song": "",
"singer": ""
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "我要跳起来啦!"
}
}]
}
}
3,返回参数说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| operateState | String | N | 11000:开始 11001:暂停 11002:继续 12003:上一个 12004:换一个 |
打开应用(201601)
1,介绍
打开应用是图灵提供的打开应用的指令,图灵会返回打开后面的应用名称和应用标识,需要先上传应用列表。
说法示例
1. 打开日历
2,输入输出
输入:打开日历
输出:
{
"code": 200,
"done": true,
"globalId": "219622701450390001",
"message": "success",
"nlpResponse": {
"intent": {
"code": 201601,
"intentName": "open_app",
"operateState": 200201,
"parameters": {
"app_name": "日历",
"app_list": [{
"package": "",
"name": "日历"
}],
"is_open": true
}
},
"results": [{
"groupType": 0,
"resultType": "text",
"values": {
"text": "正在打开日历,请稍后。"
}
}]
}
}
3,返回参数说明
| 参数 | 类型 | 说明 |
|---|---|---|
| app_name | String | app名称 |
| is_open | bool | 是否直接打开 |
| app_list | Array | 应用信息对象,信息参考AppInfo字段 |
AppInfo 字段说明
| 字段名称 | 字段类型 | 字段说明 |
|---|---|---|
| name | String | app名称 |
| package | String | app包名称 |
operateState 字段说明
| 参数 | 类型 | 是否必须 | 说明 |
|---|---|---|---|
| operateState | String | N | 200201:打开应用 |