ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### 3.2.11 漂流瓶 #### (1)功能说明 海知提供的漂流瓶,现在你可以对我说“捞瓶子”或者“扔瓶子”与有缘的陌生人聊天,匿名对话,去探索未知神秘的游戏乐趣。硬件端需要接入请联系support@ruyi.ai #### (2)接口说明 **请求方法** * POST **请求地址** * http://api.ruyi.ai/v1/message **请求参数说明** |参数名 |参数类型 | 是否必须 |参数说明 | :-----| :---| :---:|:----- |q |String| 是| 自然语言表达,例如“漂流瓶”等 |app_key| String|是 |应用开发者秘钥,注册开发者后台账号,建立虚拟助理后获得 |user_id |String| 是 |用户唯一标识,便于支持个性化语义解析。建议开发者使用 UUID 字符,且不同用户必须用不同的 user_id,防止意图串。 #### (3)返回说明 **返回参数说明** |名称 |类型| 说明 |:---|:---|:--- |code |Integer | 返回代码 |msg | String |返回代码描述 |parameters|JSON Object |解析到的实体以及服务说明 |action|String|服务的接口名称 |name| String|匹配的意图名称 |result | JSON Object| 接口返回内容 |outputs| Array| 服务输出结果,微信端使用 type 类型为 wechat 开头的内容;硬件端收到所有内容,依据需求解析使用 **返回代码说明** |返回代码 |错误类型|说明 |:---|:---|:--- |0/200 |成功 |请求成功 |400 |无效请求 |某些必需参数缺失或参数值错误,详见msg字段 |401 |未授权 |授权失败,app_key缺失或错误 |403 |请求被禁止|有效请求,但服务拒绝响应,请联系contact@ruyi.ai |408 |请求超时 |请求响应超时,一般响应时间设置为2000ms以内 |429 |短时间内大量访问 |短时间内请求数过多 |500 |内部错误 |服务处理异常 |503 |服务不可用|服务异常或正在维护 #### (4)请求示例 **请求范例** 打开漂流瓶 扔瓶子 世界和平 扔瓶子 (触发敏感词) 捞瓶子 回复 天气这么好,不要不开心 查看消息 捞瓶子 扔回海里 捞瓶子 删除瓶子 确认(取消) 退出 **请求示例唤醒** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=打开漂流瓶 (唤醒) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "打开漂流瓶", "msg_id": "fd29f3ac-bd5d-4478-99d2-c72ce407b15f", "intents": [ { "parameters": { "service": "current bottle" }, "action": "漂流瓶-开始", "name": "语音扔瓶子(请勿修改)扔瓶子-指令游戏开始", "result": { "fishingNum": 12, "blacklist": 0, "throwNum": 20, "optionTime": 1547704803184, "replyNum": "3", "visitTimes": 23 "text": "欢迎来到漂流瓶,你有3个消息未查看.你可以查看消息,或扔一个瓶子来聊聊秋天里想做的事吧", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "欢迎来到漂流瓶,你有3个消息未查看,现在说说你的梦想是什么吧" } }, { "type": "dialog", "property": { "text": "欢迎来到漂流瓶,你有3个消息未查看.你可以查看消息,或扔一个瓶子来聊聊秋天里想做的事吧", "emotion": "positive" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "b8a63b4e-ae71-4ea4-afe0-321a28390522", "id": "84b314d9-cb7b-4231-9b1a-ca8ff9141a8f" } ], "meta_process_milliseconds": 85 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=扔瓶子 (扔瓶子) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "扔瓶子", "msg_id": "63e8d89e-4e16-449a-b8cb-3927a88e2961", "intents": [ { "parameters": { "service": "current bottle" }, "action": "dialog", "name": "语音扔瓶子(请勿修改)扔瓶子-指令", "result": { "text": "一只小巧旅行瓶已经为你准备好了,赶快说出你想说的话吧", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "一只小巧旅行瓶已经为你准备好了,赶快说出你想说的话吧" } }, { "type": "dialog", "property": { "text": "嗯,瓶子准备好了,不如现在许个愿吧", "emotion": "calm" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "b8a63b4e-ae71-4ea4-afe0-321a28390522", "id": "3c168bfa-75a9-45c9-8b46-dadbbc78fc2d" } ], "meta_process_milliseconds": 194 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=世界和平 (许愿) 返回结果 ```json {"code": 0, "msg": "ok", "result" { "_text": "世界和平", "msg_id": "822959ec-2589-4fc1-bc56-ad325535c7ea", "intents": [ { "parameters": { "text": "世界和平", "service": "current bottle" }, "action": "扔瓶子", "name": "扔瓶子-输入", "result": { "timeStart": "1547704880097", "ownerId": "ruyi-test-b8a63b4e-ae71-4ea4-afe0-321a28390522", "textStart": "世界和平", "currentText": "世界和平", "id": "096e113dd89bcaa77f812fb6e7c5230b" "text": " 好的,我现在把你的瓶子扔出去啦!不如再扔一个吧", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": " 好的,我现在把你的瓶子扔出去啦!不如再扔一个吧" } }, { "type": "dialog", "property": { "text": " 好的,我现在把你的瓶子扔出去啦!不如扔个瓶子吧", "emotion": "positive" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "b8a63b4e-ae71-4ea4-afe0-321a28390522", "id": "d07457bd-7989-4c04-aacf-a1db462c2dc8" } ], "meta_process_milliseconds": 398 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=寂寞美眉 (敏感词) 返回结果 ``` { code: 0, msg: "ok", result: { _text: "寂寞美眉", msg_id: "71bafd23-c3c8-4efc-8ab9-680df6801180", intents: [{ parameters: { any: "", any1: "" }, action: "黑名单", name: "黑名单大佬", result: { code: 200, response: { code: 0, msg: "成功", result: { fishingNum: 8, blacklist: 1, throwNum: 20, optionTime: 1578466302388 } }, text: "不要跟我说这些,你可以继续跟我说扔瓶子或捞瓶子,不想玩了可以退出", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: "不要跟我说这些,您可以继续跟我说扔瓶子或捞瓶子,不想玩了跟我说退出" } }, { type: "dialog", property: { text: "不要跟我说这些,你可以继续跟我说扔瓶子或捞瓶子,不想玩了可以退出", emotion: "negative" } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "eb5a1906-da4f-4ed3-982d-404b7eed8984", id: "8c65b006-7f2b-4e90-bad2-b38eb05384e6" }], meta_process_milliseconds: 230 } } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=捞瓶子 (捞瓶子) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "捞瓶子", "msg_id": "1043ae8b-5364-4cc7-872a-363c431e45ba", "intents": [ { "parameters": { "service": "current bottle" }, "action": "捞瓶子", "name": "漂流瓶需要传递id(请勿修改)捞瓶子-指令", "result": { "timeStart": "1530066916354", "ownerId": "0000000", "textStart": "心情差", "currentText": "心情差", "id": "e36adb0dfd8ff616a1f3c5de23d19987", "timeFished": "1547704888899", "fisherId": "ruyi-test-b8a63b4e-ae71-4ea4-afe0-321a28390522", "justFished": "1" "text": "捡到啦!瓶子内容是:心情差。\\n想回复的话跟我说“回复”,不合适的内容可以投诉哦", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "捡到啦!瓶子内容是:心情差。\\n想回复的话跟我说“回复”,不合适的内容可以投诉哦" } }, { "type": "dialog", "property": { "text": "捡到啦!瓶子内容是:心情差。\\n想回复的话跟我说“回复”,不合适的内容可以投诉哦", "emotion": "positive" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "b8a63b4e-ae71-4ea4-afe0-321a28390522", "id": "0db7abb1-00d4-4431-a791-04a63a0c9240" } ], "meta_process_milliseconds": 214 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=天气这么好,不要不开心 (回复内容) 返回结果 ```json {"code": 0, "msg": "ok", "result" { "_text": "天气这么好,不要不开心", "msg_id": "649c4f14-32fa-4080-8bb8-1700f9d40930", "intents": [ { "parameters": { "text": "天气这么好不要不开心", "service": "current bottle" }, "action": "回复", "name": "捞瓶子and看回复-回复-内容", "result": { "timeStart": "1530066916354", "ownerId": "0000000", "textStart": "心情差", "currentText": "天气这么好不要不开心", "id": "e36adb0dfd8ff616a1f3c5de23d19987", "timeFished": "1547704888899", "fisherId": "ruyi-test-b8a63b4e-ae71-4ea4-afe0-321a28390522", "timeSendMessage": "1547704919589", "replyText": "心情差" "text": " 好的,现在把瓶子扔出去啦!再扔一个吧", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": " 好的,现在把瓶子扔出去啦!再扔一个吧" } }, { "type": "dialog", "property": { "text": " 好的,现在把瓶子扔出去啦!再扔一个吧", "emotion": "positive" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "b8a63b4e-ae71-4ea4-afe0-321a28390522", "id": "e725af15-5d12-409e-825a-cfb1c94c4d17" } ], "meta_process_milliseconds": 117 } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=扔回海里 (前提是捞到了瓶子) 返回结果 ```json { code: 0, msg: "ok", result: { _text: "扔回海里", msg_id: "827ad9ff-865f-42fa-859d-9f30271f0dba", intents: [{ parameters: {}, action: "扔回海里", name: "扔回海里", result: { code: 200, response: { code: 0, msg: "成功", result: { timeStart: "1560356083030", ownerId: "6MUQILgRCO1BUMuO9uQ30g==", textStart: "我的超能力就是要每个人都变的快乐", audioId: "654ecfa11840800f284717e1", currentText: "我的超能力就是要每个人都变的快乐", id: "a6e935889e359453770afcf8c7e76a0a" } }, text: " 好的,已经送它重回海洋的怀抱啦。", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: " 好的,已经送它重回海洋的怀抱啦。" } }, { type: "voice", property: { name: null, voice_url: "https://qiniu.ruyi.ai/FiUfAqm4ZcZgFOSdQYCYsd76NWy9/small_wave1.mp3" } }, { type: "dialog", property: { text: " 好的,已经送它重回海洋的怀抱啦。", emotion: "positive" } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "eb5a1906-da4f-4ed3-982d-404b7eed8984", id: "5c754054-bcc4-4dce-9529-6e1b3b97f85b" }], meta_process_milliseconds: 200 } } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=删除瓶子 (前提是捞到了瓶子) 返回结果 ```json { code: 0, msg: "ok", result: { _text: "删除瓶子", msg_id: "e6dc09f4-bbf2-4dc0-b2ba-79c609c7da82", intents: [{ parameters: {}, action: "dialog", name: "捞瓶子and看回复-快删", result: { text: "瓶子即将被粉碎哦,要继续吗", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: "瓶子即将被粉碎哦,要继续吗" } }, { type: "dialog", property: { text: "垃圾瓶子即将被粉碎哦,要继续吗", emotion: "suspect" } } ], score: "0.9998858353147755", scoreColor: "c4", is_match: 1, skill_id: "eb5a1906-da4f-4ed3-982d-404b7eed8984", id: "4752a33c-00fb-4721-8ef8-d8cd505ff510" }], meta_process_milliseconds: 39 } } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=确认 (前提是要求删除瓶子) 返回结果 ```json { code: 0, msg: "ok", result: { _text: "确认", msg_id: "e28fe0a7-5343-47a2-8399-6c5e352e1c9e", intents: [{ parameters: { blockedLimit: "5", blockedTime: "5" }, action: "标为垃圾", name: "捞瓶子and看回复-快删-确认", result: { code: 200, response: { code: 1, msg: "失败null" }, text: " 好的,感谢您对海洋环境的支持。", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: " 好的,感谢您对海洋环境的支持。" } }, { type: "voice", property: { name: "[3100] 综合音效库-玻璃秋天碎片到大1(glass-f_爱给网_aigei_com.mp3", voice_url: "https://qiniu.ruyi.ai/FpQQ6osBq4VzzM1exWwjoqUZpeq5/[3100] 综合音效库-玻璃秋天碎片到大1(glass-f_爱给网_aigei_com.mp3" } }, { type: "dialog", property: { text: " 好的,感谢你对海洋环境的支持。", emotion: "positive" } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "eb5a1906-da4f-4ed3-982d-404b7eed8984", id: "7ae8fcc0-2de0-4337-acad-4b3d1507c738" }], meta_process_milliseconds: 124 } } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=取消 (前提是要求删除瓶子) 返回结果 ```json { code: 0, msg: "ok", result: { _text: "取消", msg_id: "afd16361-203e-460d-9f20-8e937d025942", intents: [{ parameters: {}, action: "dialog", name: "捞瓶子and看回复-快删-取消", result: { text: "好的,不投诉的话就帮你扔回大海了。咱们继续捞瓶子吧", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: "好的,不删的话就帮您扔回大海了" } }, { type: "dialog", property: { text: "好的,不投诉的话就帮你扔回大海了。咱们继续捞瓶子吧", emotion: "positive" } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "eb5a1906-da4f-4ed3-982d-404b7eed8984", id: "009c207e-1395-4e22-b0e2-180a2b454870" }], meta_process_milliseconds: 38 } } ``` **请求示例正确** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=查看消息 (查看消息) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "查看消息", "msg_id": "c6917f72-e7c2-4290-9a20-070cef8f9054", "intents": [ { "parameters": { "service": "current bottle" }, "action": "查看回复", "name": "漂流瓶需要传递id(请勿修改)看回复", "result": { "timeStart": "1535682234970", "ownerId": "ruyi-test-b8a63b4e-ae71-4ea4-afe0-321a28390522", "textStart": "打开诗词大会", "currentText": "不会", "id": "e0b97cfc1520b6c40a816fe84d3c3f08", "timeFished": "1537950631884", "fisherId": "12345", "timeSendMessage": "1537950658584", "replyText": "打开诗词大会", "isChecked": "true", "needToReplyNum": "3", "visitTimes": 14 "text": "你有3消息未回复,听完消息要回复的话跟我说回复,不喜欢可以投诉。\\n你扔的瓶子“打开诗词大会”的回复内容是:不会", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "你有3消息未回复,听完消息要回复的话跟我说回复,不喜欢可以投诉。\\n你扔的瓶子“打开诗词大会”的回复内容是:不会" } }, { "type": "dialog", "property": { "text": "。你扔的瓶子打开诗词大会的回复内容是:", "emotion": "calm" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "b8a63b4e-ae71-4ea4-afe0-321a28390522", "id": "f43bc859-dda4-4e13-ab71-4caf0456726e" } ], "meta_process_milliseconds": 129 } ``` **请求示例退出** http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=退出 (退出游戏) 返回结果 ```json {"code": 0, "msg": "ok", "result"{ "_text": "退出", "msg_id": "5fa46f7d-1030-42af-805a-92a09f57d461", "intents": [ { "parameters": { "service": "current bottle" }, "action": "退出", "name": "退出如意技能", "result": { "timeStart": "1535682234970", "ownerId": "ruyi-test-b8a63b4e-ae71-4ea4-afe0-321a28390522", "textStart": "打开诗词大会", "currentText": "不会", "id": "e0b97cfc1520b6c40a816fe84d3c3f08", "timeFished": "1537950631884", "fisherId": "12345", "timeSendMessage": "1537950658584", "replyText": "打开诗词大会", "isChecked": "true" "text": "你即将离开漂流瓶,欢迎下次再来~", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "你即将离开漂流瓶,欢迎下次再来~" } }, { "type": "dialog", "property": { "text": "你即将离开漂流瓶,欢迎下次再来~", "emotion": "calm" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "b8a63b4e-ae71-4ea4-afe0-321a28390522", "id": "dedb3efe-df63-4b56-b7df-6e1e80c4f85c" } ], "meta_process_milliseconds": 248 } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |throwNum| String |用户可以扔瓶子的次数 |fishingNum| String |用户可以捞瓶子的次数 |blacklist| String |用户说敏感词的次数 |optionTime |String |用户上次抛扔瓶子的时间 |timeStart |String |用户扔出瓶子的初始时间 |ownerId| String |扔瓶子用户的ID |textStart| String |扔瓶子时瓶子的初始内容 |id |String |瓶子的唯一标示 |timeFished |String |用户捞起瓶子的时间 |fisherId |String| 捞瓶子用户的ID |currentText| String| 瓶子内待查看的文字信息 |audioId |String |瓶子内语音文件ID |replyText |String| 瓶子内上次被回复的文字信息 |checkTimes| String |用户调用该接口的次数 |playTimes |int| 用户进入游戏的次数 |timeSendMessage| String |用户回复消息的时间 |text |String| 用户回复消息的内容 |currentText |String |瓶子内待查看的文字信息 |replyText |String |瓶中被回复的消息内容 **指令清单** |指令名称|范例| |:---|:--- |唤醒 | 打开漂流瓶 |捞瓶子 | 捞瓶子 |回复别的用户发来的消息 | 回复 |瓶子放回海里|扔回海里 |扔瓶子| 扔瓶子 |许愿 | 世界和平 |查看消息 | 查看消息 |删除 | 删除瓶子 |确认删除 | 确认 |取消删除 | 取消 |退出 | 退出