### 3.2.8 猜猜我是谁 #### (1)功能说明 猜猜我是谁是一款为幼儿园小朋友打造的职业认知游戏,帮助小朋友增长社会知识。根据机器人对职业的不同描述,小朋友来猜是谁,是老师?医生?农民?…… 没关系,即使猜不对,机器人会最终揭晓身份哒!快来玩猜猜我是谁,不同的职业角色在等着小朋友们去发现哦! #### (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": "f368c98c-c857-4d13-a029-75ac943b482b",    "intents": [        {            "parameters": {                "correctAnswer": "园丁",                "currentQuestionIndex": "1",                "currentDescribeIndex": "1",                "userAnswer": "园丁",                "correctAnswerCount": "0",                "automaticExit": "0",                "service": "guessWho"            },            "action": "玩游戏",            "name": "玩游戏",            "result": {                        "describe": "我善于观察生活",                        "introduce": "",                        "answer": "作家",                        "previousCorrectAnswer": "",                        "correctAnswerCount": 1,                        "currentQuestionIndex": 2,                        "currentDescribeIndex": 1,                        "isCorrectly": 1,                        "automaticExit": 0                        "text": "猜对啦,这对你太简单啦!现在你猜我是谁,我善于观察生活,猜到了吗?",                         "type": "dialog"            },            "outputs": [                {                    "type": "wechat.text",                    "property": {                        "text": "猜对啦,这对你太简单啦!现在你猜我是谁,我善于观察生活,猜到了吗?"                    }                },                {                    "type": "voice",                    "property": {                        "name": null,                        "voice_url": "http://image.ruyi.ai/%E7%AD%94%E5%AF%B9.mp3"                    }                },                {                    "type": "dialog",                    "property": {                        "text": "哇,一下揭穿了我的身份!真聪明!现在你猜我是谁,我善于观察生活,猜到了吗?",                        "emotion": "naughty"                    }                }            ],            "score": "1.0",            "scoreColor": "c4",            "is_match": 1,            "skill_id": "ab5dfa85-b8e0-4c49-bf74-6ea914de15e5",            "id": "174fc71a-f205-48ad-aad1-09a7cfce2c3b"        }    ],    "meta_process_milliseconds": 176 } ``` **请求示例重复** 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": "d7ccc05d-f5f4-4c25-a007-1f94b021f548",    "intents": [        {            "parameters": {                "repeat": "1",                "correctAnswer": "作家",                "currentDescribeIndex": "1",                "correctAnswerCount": "1",                "currentQuestionIndex": "2",                "automaticExit": "0",                "service": "guessWho"            },            "action": "玩游戏",            "name": "重复",              "result": {                        "describe": "我善于观察生活",                        "introduce": "",                        "answer": "作家",                        "previousCorrectAnswer": "",                        "correctAnswerCount": 1,                        "currentQuestionIndex": 2,                        "currentDescribeIndex": 1,                        "isCorrectly": 0,                        "automaticExit": 0                         "text": "竖起耳朵仔细听哦,我善于观察生活。 你知道我是谁吗?",                          "type": "dialog"            },            "outputs": [                {                    "type": "wechat.text",                    "property": {                        "text": "竖起耳朵仔细听哦,我善于观察生活。 你知道我是谁吗?"                    }                },                {                    "type": "dialog",                    "property": {                        "text": "竖起耳朵仔细听哦,我善于观察生活。 你知道我是谁吗?",                        "emotion": "suspect"                    }                }            ],            "score": "1.0",            "scoreColor": "c4",            "is_match": 1,            "skill_id": "ab5dfa85-b8e0-4c49-bf74-6ea914de15e5",            "id": "bd40a0d4-bd76-4e37-813d-df5a01bec5b9"        }    ],    "meta_process_milliseconds": 216 } ``` **请求示例错误** 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": "4d25de0a-852d-4a87-83b8-c76ebbf645d9",    "intents": [        {            "parameters": {                "correctAnswer": "作家",                "currentQuestionIndex": "2",                "currentDescribeIndex": "1",                "userAnswer": "警察",                "correctAnswerCount": "1",                "automaticExit": "0",                "service": "guessWho"            },            "action": "玩游戏",            "name": "玩游戏",            "result": {                        "describe": "我喜欢和文字打交道",                        "introduce": "",                        "answer": "作家",                        "previousCorrectAnswer": "",                        "correctAnswerCount": 1,                        "currentQuestionIndex": 2,                        "currentDescribeIndex": 2,                        "isCorrectly": 0,                        "automaticExit": 0                        "text": "再猜猜看吧!我喜欢和文字打交道。 你知道我是谁吗?",                        "type": "dialog"            },            "outputs": \[                {                    "type": "wechat.text",                    "property": {                        "text": "再猜猜看吧!我喜欢和文字打交道。 你知道我是谁吗?"                    }                },                {                    "type": "voice",                    "property": {                        "name": null,                        "voice\_url": "http://image.ruyi.ai/%E7%AC%AC%E4%B8%80%E6%AC%A1%E5%9B%9E%E7%AD%94%E9%94%99%E8%AF%AF.mp3"                    }                },                {                    "type": "dialog",                    "property": {                        "text": "再猜猜看吧!我喜欢和文字打交道。 你知道我是谁吗?",                        "emotion": "suspect"                    }                }            ],            "score": "1.0",            "scoreColor": "c4",            "is_match": 1,            "skill_id": "ab5dfa85-b8e0-4c49-bf74-6ea914de15e5",            "id": "174fc71a-f205-48ad-aad1-09a7cfce2c3b"        }    ],    "meta_process_milliseconds": 95 } ``` **请求示例退出** 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": "e9b8f75c-4861-4be2-a0bd-c572c1c8ef23",    "intents": [        {            "parameters": {                "退出词典": "结束",                "correctAnswerCount": "1",                "service": "guessWho"            },            "action": "退出",            "name": "退出如意技能",             "result": {                        "introduce": "",                        "previousCorrectAnswer": "",                        "correctAnswerCount": 1,                        "maxScore": 1,                        "isCorrectly": 0,                        "automaticExit": 1                "text": "你在猜猜我是谁中猜对了1个人物,加油呀!",                "type": "dialog"            },            "outputs": [                {                    "type": "wechat.text",                    "property": {                        "text": "你在猜猜我是谁中猜对了1个人物,加油呀!"                    }                },                {                    "type": "dialog",                    "property": {                        "text": "你在猜猜我是谁中猜对了1个人物,加油呀!",                        "emotion": "suspect"                    }                }            ],            "score": "1.0",            "scoreColor": "c4",            "is_match": 1,            "skill_id": "ab5dfa85-b8e0-4c49-bf74-6ea914de15e5",            "id": "f891b32c-2483-4465-9b4e-e007396010af"        }    ],    "meta_process_milliseconds": 174 } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |userAnswer|String|用户回答的答案:第一次出题时可不用传值,其余情况传入用户所说的答案 |correctAnswer | String | 题目正确答案:出题时,机器返回的数据中包含了正确答案(result的answer字段),用户回答时需传入进行答案匹配,第一次出题时可不传值 |currentQuestionIndex | int |答题过程中传入当前题目的序号(result中的currentQuestionIndex字段),第一次出题时/重玩等传0,参数默认值为0 |currentDescribeIndex|int|答题过程中传入当前题目的描述顺序(result的currentDescribeIndex字段),当需要跳过当前题目时,传0,参数的默认值为0 |correctAnswerCount | int |回答正确题目的数量(result的correctAnswerCount字段),每次用户答题时传回当前答对题目的数量,新出题时传0,默认为0 |size|int|获取题目的数量,默认50 |repeat | int |是否重复,1为重复,0为不重复,不传值则默认传0 |jump|int|是否跳过,1为跳过,0为不跳过,不传值则默认传0 |describe| String |当前问题的一句话介绍(同previousCorrectAnswer,仅用户三次回答不对和跳过的时候存在,其余返回空) |introduce|String|当前问题的一句话介绍(同previousCorrectAnswer,仅用户三次回答不对和跳过的时候存在,其余返回空) |answer | String |当前问题答案 |isCorrectly|String|用户答案是否正确,正确返回回答正确时的currentDescribeIndex,其余返回0 |previousCorrectAnswer | String |前一个问题的答案(仅用户三次回答不对和跳过的时候存在,其余返回空) **指令清单** |指令名称|范例| |:---|:--- |唤醒 | 猜猜我是谁 |说职业 | 园丁 |重复 | 重复 |退出 | 退出