多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
### 3.2.5 动脑猜猜 #### (1)功能说明        动脑猜猜是猜谜游戏,用户说“动脑猜猜"、“猜谜”、“猜谜语”等关键词语时可进入游戏,有数字,称呼,乘法,水果,动物,灯谜 6 种关卡,其中最简单的是数字,最难的是灯谜,难度逐项递增,更增添了趣味感。机器人出题,用户回答,有两次回答机会,两次都未回答对机器人就会给出正确答案,可选择跳过。 #### (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": "b2c76ed1-0747-478a-a53a-364d4ed853a2", "intents": [{ "parameters": { "tag": "水果", "text": "樱桃", "score": "0", "numChanceLeft": "1", "prevQuestion": "小小车厘子,红红小果子(打一水果)(2个字)", "prevAnswer": "樱桃", "prevResult": "", "answer": "樱桃", "lastAnswer": "樱桃", "lastQuestion": "小小车厘子,红红小果子(打一水果)(2个字)", "game-status": "playing", "service": "dongnaocaicai" }, "action": "sys.action.game/dongnaocaicai/play", "name": "猜猜-玩游戏", "result": { "lastQuestion": "圆圆的水果高高挂,喝完水来把肉吃(打一水果)(2个字)", "lastAnswer": "椰子", "lastExplanation": "", "explanationUserSay": "", "score": 1, "totalNumUserSay": 1, "numChanceLeft": 2, "prevQuestion": "小小车厘子,红红小果子(打一水果)(2个字)##圆圆的水果高高挂,喝完水来把肉吃(打一水果)(2个字)", "prevAnswer": "樱桃##椰子", "prevResult": "1", "isRightAnswer": true, "totalNumQuestion": 2, "text": "你说对了!正确答案是:樱桃。第2题,圆圆的水果高高挂,喝完水来把肉吃(打一水果)(2个字)", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "你说对了!正确答案是:樱桃。第2题,圆圆的水果高高挂,喝完水来把肉吃(打一水果)(2个字)" } }, { "type": "dialog", "property": { "text": "你说对了!正确答案是:樱桃。第2题,圆圆的水果高高挂,喝完水来把肉吃(打一水果)(2个字)", "emotion": "calm" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "8a5fa1c8-324b-4564-b198-cf59f87d5911" }], "meta_process_milliseconds": 151 } } ``` **请求示例** (跳过) * 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": "ba0d7d60-ebc0-46f9-9952-1b4bbcd5729b", "intents": [{ "parameters": { "tag": "水果", "text": "text", "score": "0", "numChanceLeft": "1", "prevQuestion": "浑身黄袍皮粗糙,头顶冠芽不算高(打一水果)(2个字)", "prevAnswer": "菠萝", "prevResult": "", "answer": "菠萝", "lastAnswer": "菠萝", "lastQuestion": "浑身黄袍皮粗糙,头顶冠芽不算高(打一水果)(2个字)", "game-status": "playing", "service": "dongnaocaicai" }, "action": "sys.action.game/dongnaocaicai/play", "name": "猜猜-玩游戏-跳过", "result": { "lastQuestion": "高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "lastAnswer": "甘蔗", "lastExplanation": "", "explanationUserSay": "", "score": 0, "totalNumUserSay": 1, "numChanceLeft": 2, "prevQuestion": "浑身黄袍皮粗糙,头顶冠芽不算高(打一水果)(2个字)##高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "prevAnswer": "菠萝##甘蔗", "prevResult": "0", "isRightAnswer": false, "totalNumQuestion": 2, "text": "正确答案是:菠萝。第2题,高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "正确答案是:菠萝。第2题,高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)" } }, { "type": "dialog", "property": { "text": "正确答案是:菠萝。第2题,高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "emotion": "happy" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "0d74bc6e-7881-46bb-acb3-3568d82c7ba9" }], "meta_process_milliseconds": 71 } } ``` **请求示例** (重复) * 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": "59b9dcb1-603a-4b85-a902-ac6b02d3ca26", "intents": [{ "parameters": { "tag": "水果", "text": "text", "score": "0", "numChanceLeft": "3", "prevQuestion": "浑身黄袍皮粗糙,头顶冠芽不算高(打一水果)(2个字)##高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "prevAnswer": "菠萝##甘蔗", "prevResult": "0", "answer": "甘蔗", "lastAnswer": "甘蔗", "lastQuestion": "高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "game-status": "playing", "service": "dongnaocaicai" }, "action": "sys.action.game/dongnaocaicai/play", "name": "猜猜-玩游戏-重复题目", "result": { "lastQuestion": "高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "lastAnswer": "甘蔗", "lastExplanation": "", "explanationUserSay": "", "score": 0, "totalNumUserSay": 1, "numChanceLeft": 2, "prevQuestion": "浑身黄袍皮粗糙,头顶冠芽不算高(打一水果)(2个字)##高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "prevAnswer": "菠萝##甘蔗", "prevResult": "0", "isRightAnswer": false, "totalNumQuestion": 2, "text": "第2题, 高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "第2题, 高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)" } }, { "type": "dialog", "property": { "text": "第2题, 高高瘦瘦似竹子,糖水丰富甜如丝(打一水果)(2个字)", "emotion": "happy" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "060944b8-36c5-41ec-a126-4f5fce89f784" }], "meta_process_milliseconds": 48 } } ``` **请求示例** (退出) * 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": "b2dda37a-6ebd-484e-aaab-0586ce27bf88", "intents": [{ "parameters": { "tag": "水果", "score": "0", "game-status": "over", "totalNumQuestion": "2", "service": "dongnaocaicai" }, "action": "0", "name": "答题中-退出", "result": { "text": "你在称呼猜猜中说答对了0道题,再接再厉哦!欢迎下次再玩动脑猜猜。", "type": "dialog" }, "outputs": [{ "type": "wechat.text", "property": { "text": "你在称呼猜猜中说答对了0道题,再接再厉哦!欢迎下次再玩动脑猜猜。" } }, { "type": "dialog", "property": { "text": "你在称呼猜猜中说答对了0道题,再接再厉哦!欢迎下次再玩动脑猜猜。", "emotion": "calm" } }], "score": "1.0", "scoreColor": "c4", "is_match": 1, "id": "0099f058-7e63-4080-9c1d-56596a0acb61" }], "meta_process_milliseconds": 88 } } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |tag|String|选择类别 |isRightAnswer|Boolean |判断是否为正确答案,是则为 true |numChanceLeft|String|剩余回答机会 |score|Integer|当前得分 |prevQuestion|String|上一个问题和之前的问题 |prevAnswer|String|上一个答案和之前的答案 |lastAnswer|String|上一个答案 |lastQuestion|String| 上一个问题 |game-status|String|游戏当前所处的状态 |answer|String|当前这一轮的答案 |totalNumQuestion|String|所回答的问题总数 **指令清单** | 指令名称 | 范例 | | :--- | :--- | | 唤醒| 动脑猜猜| | 选择类型| 数字| | 玩游戏| 1| | 重复| 重复| | 跳过| 跳过| | 退出| 退出|