### 3.2.12 诗词大会 #### (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": "22baaf5d-4fe5-4e5b-a6af-a7110d208d72", "intents": [ { "parameters": { "打开诗词大会": "打开诗词大会", "any": "", "service": "poetryCongress" }, "action": "唤醒", "name": "打开诗词大会", "result": { "poetCollectInfo": { "playCount": 159, "collectedPoet": [ "诗魔白居易", "诗狂贺知章", "诗杰王勃", "诗豪刘禹锡" ], "notCollectPoet": [ "诗佛王维", "诗鬼李贺", "诗圣杜甫", "诗仙李白" ] } "text": "欢迎回到诗词大会。你可以了解玩法或现在开始答题。", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "欢迎回到诗词大会。你可以了解玩法或现在开始答题。" } }, { "type": "voice", "property": { "name": "诗词大会.m4a", "voice_url": "https://qiniu.ruyi.ai/FheQoy3Yh__bW5s_CqQ36xxkVLuv/诗词大会.m4a" } }, { "type": "dialog", "property": { "text": "欢迎回到诗词大会。你可以了解玩法或现在开始答题。", "emotion": "positive" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "d5a90c2c-d1ef-48d0-8301-adb350042d6d", "id": "00f8eebf-5931-4354-9e15-e58f2a371a00" } ], "meta_process_milliseconds": 171 } ``` **请求示例正确** 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": "7b643234-74f1-4530-81a4-a670490e0236", "intents": [ { "parameters": { "any1": "答题", "any": "", "service": "poetryCongress" }, "action": "开始", "name": "开始", "result": { "chapter": "明辨是非", "question": { "correctGroup": { "questionType": "诗句,诗句", "verse1": "会当凌绝顶", "verse2": "一览众山小" }, "questionType": "诗句,诗句", "verse1": "会当凌绝顶", "verse2": "便引诗情到碧霄", "poemIds": "57,4,119" }, "answer": "错误", "qNo": 1, "chapterQno": 1, "score": 0, "chapterScore": 0, "chanceToAnswer": 2 "text": "第一关:明辨是非。说“正确”或“错误”来答题。第1题,诗句“会当凌绝顶“的下一句是“便引诗情到碧霄”", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "第一关:明辨是非。说“正确”或“错误”来答题。第1题,诗句“会当凌绝顶“的下一句是“便引诗情到碧霄”" } }, { "type": "dialog", "property": { "text": "第一关:明辨是非。说“正确”或“错误”来答题。第1题,诗句“会当凌绝顶“的下一句是“便引诗情到碧霄”", "emotion": "calm" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "d5a90c2c-d1ef-48d0-8301-adb350042d6d", "id": "99b233c4-0152-4adb-a04d-5c64b3924e95" } ], "meta_process_milliseconds": 169 } ``` **请求示例正确** 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": "162e9861-d03a-4343-8584-d614fa8f95da", "intents": [ { "parameters": { "判断": "错误", "text": "错误", "service": "poetryCongress" }, "action": "玩游戏", "name": "第一关", "result": { "chapter": "明辨是非", "question": { "correctGroup": { "questionType": "诗人,诗句", "poet": "杜甫", "verse": "江船火独明" }, "questionType": "诗人,诗句", "poet": "王安石", "verse": "江船火独明", "poemIds": "121,61,73" }, "answer": "错误", "isRight": true, "qNo": 2, "chapterQno": 2, "score": 1, "chapterScore": 1, "chanceToAnswer": 2, "lastQuestion": { "correctGroup": { "questionType": "诗句,诗句", "verse1": "会当凌绝顶", "verse2": "一览众山小" }, "questionType": "诗句,诗句", "verse1": "会当凌绝顶", "verse2": "便引诗情到碧霄", "poemIds": "57,4,119" }, "lastAnswer": "错误" "text": "答对了,真厉害!古诗“会当凌绝顶”的下一句是“一览众山小”。第2题,诗句“江船火独明“是出自王安石", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "答对了,真厉害!古诗“会当凌绝顶”的下一句是“一览众山小”。第2题,诗句“江船火独明“是出自王安石" } }, { "type": "dialog", "property": { "text": "答对了,真厉害!古诗“会当凌绝顶”的下一句是“一览众山小”。第2题,诗句“江船火独明“是出自王安石", "emotion": "happy" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "d5a90c2c-d1ef-48d0-8301-adb350042d6d", "id": "1b8acdf1-d287-455b-9172-0ea531abccf1" } ], "meta_process_milliseconds": 425 } ``` **请求示例错误** 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": "8b5cf2e2-4d38-4f27-bbd9-719ad3bcac32", "intents": [ { "parameters": { "判断": "正确", "text": "正确", "service": "poetryCongress" }, "action": "玩游戏", "name": "第一关", "result": { "chapter": "明辨是非", "question": { "correctGroup": { "questionType": "题目,诗句", "title": "滁州西涧", "verse": "上有黄鹂深树鸣" }, "questionType": "题目,诗句", "title": "滁州西涧", "verse": "上有黄鹂深树鸣", "poemIds": "108" }, "answer": "正确", "isRight": false, "qNo": 3, "chapterQno": 3, "score": 1, "chapterScore": 1, "chanceToAnswer": 2, "lastQuestion": { "correctGroup": { "questionType": "诗人,诗句", "poet": "杜甫", "verse": "江船火独明" }, "questionType": "诗人,诗句", "poet": "王安石", "verse": "江船火独明", "poemIds": "121,61,73" }, "lastAnswer": "错误" "text": "答错了,好可惜!诗句“江船火独明”是出自杜甫。第3题,诗句“上有黄鹂深树鸣“是出自古诗滁州西涧", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "答错了,好可惜!诗句“江船火独明”是出自杜甫。第3题,诗句“上有黄鹂深树鸣“是出自古诗滁州西涧" } }, { "type": "dialog", "property": { "text": "答错了,好可惜!诗句“江船火独明”是出自杜甫。第3题,诗句“上有黄鹂深树鸣“是出自古诗滁州西涧", "emotion": "calm" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "d5a90c2c-d1ef-48d0-8301-adb350042d6d", "id": "1b8acdf1-d287-455b-9172-0ea531abccf1" } ], "meta_process_milliseconds": 355 ``` **请求示例正确** 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": "862d8d72-d156-4acb-b492-90d319f3356b", "intents": [ { "parameters": { "service": "poetryCongress" }, "action": "跳过", "name": "第一关跳过", "result": { "code": 200, "response": { "code": 0, "msg": "成功", "result": { "chapter": "明辨是非", "question": { "correctGroup": { "questionType": "题目,诗句", "title": "忆江南", "verse": "日出江花红似火" }, "questionType": "题目,诗句", "title": "忆江南", "verse": "日出江花红似火", "poemIds": "85" }, "answer": "正确", "isRight": false, "qNo": 4, "chapterQno": 4, "score": 1, "chapterScore": 1, "chanceToAnswer": 0, "lastQuestion": { "correctGroup": { "questionType": "题目,诗句", "title": "滁州西涧", "verse": "上有黄鹂深树鸣" }, "questionType": "题目,诗句", "title": "滁州西涧", "verse": "上有黄鹂深树鸣", "poemIds": "108" }, "lastAnswer": "正确" } }, "text": "好,跳过前公布正确答案:诗句“上有黄鹂深树鸣”是出自滁州西涧。第4题,诗句“日出江花红似火“是出自古诗忆江南", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "好,跳过前公布正确答案:诗句“上有黄鹂深树鸣”是出自滁州西涧。第4题,诗句“日出江花红似火“是出自古诗忆江南" } }, { "type": "dialog", "property": { "text": "好,跳过前公布正确答案:诗句“上有黄鹂深树鸣”是出自滁州西涧。第4题,诗句“日出江花红似火“是出自古诗忆江南", "emotion": "positive" } }, "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "d5a90c2c-d1ef-48d0-8301-adb350042d6d", "id": "9c23cfbe-58bf-40e4-9da0-17e499db22f7" } ], "meta_process_milliseconds": 167 } ``` **请求示例退出** 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": "7c65fc2c-2138-4932-8410-c28202e40e95", "intents": [ { "parameters": { "text": "退出", "service": "poetryCongress" }, "action": "玩游戏", "name": "退出如意技能", "result": { "chapter": "明辨是非", "question": { "correctGroup": { "questionType": "诗人,诗句", "poet": "毛泽东", "verse": "风华正茂" }, "questionType": "诗人,诗句", "poet": "杜甫", "verse": "风华正茂", "poemIds": "55,67,32" }, "answer": "错误", "isRight": false, "qNo": 5, "chapterQno": 5, "score": 1, "chapterScore": 1, "chanceToAnswer": 0, "lastQuestion": { "correctGroup": { "questionType": "题目,诗句", "title": "忆江南", "verse": "日出江花红似火" }, "questionType": "题目,诗句", "title": "忆江南", "verse": "日出江花红似火", "poemIds": "85" }, "lastAnswer": "正确" "text": "好的,下次准备好跟我说打开诗词大会哦", "type": "dialog" }, "outputs": [ { "type": "wechat.text", "property": { "text": "你在诗词大会的第一关答对了1题,总共答对了1题,再接再厉哦" } }, { "type": "dialog", "property": { "text": "你在诗词大会的第一关答对了1题,总共答对了1题,再接再厉哦", "emotion": "calm" } } ], "score": "1.0", "scoreColor": "c4", "is_match": 1, "skill_id": "d5a90c2c-d1ef-48d0-8301-adb350042d6d", "id": "b5646f63-d40a-454a-9aba-9017ad31946e" } ], "meta_process_milliseconds": 179 } ``` **详细参数说明** |名称|类型|说明| |:---|:---|:--- |service | String |服务名称 |poetsToCollect| String |所有可收集的诗人卡片名称列表 |poetCollectInfo| Object |用户诗人卡片收集信息 |playCount| int |用户玩游戏次数,首次进入为0 |collectedPoet| List |已获取的诗人卡片名称列表 |notCollectPoet| List |未获取的诗人卡片名称列表 |chapter| String |章节关卡,分为“明辨是非”,“对答如流”,“诗词捉迷藏” |question| Object |新的题目信息,具体参考题目信息说明 |answer |String 新的题目答案 |qNo| int |当前题号 |chapterScore| int |当前章节积分 |score| int |总积分 correctGroup| Object| “明辨是非”章节中,题目对应正确的组合,内容与题目类型对应,参考明辨是非题目类型说明 |questionType |String |明辨是非题目类型,分为"诗人,题目","诗人,诗句","题目,诗句","诗句,诗句" |poet |String |诗人名称 |title |String |诗词标题 |verse |String| 诗句 |text |String |用户所说原文 |lastQuestion |Object |上一道题目信息,具体参考题目信息说明 |isRight| boolean |上一题是否回答正确 |mission| int |关卡,1表示第一关,2表示第二关 |count| int |通关次数 |playTimes| int |用户进入游戏的次数 **指令清单** |指令名称|范例| |:---|:--- |唤醒 | 打开诗词大会 |游戏玩法介绍 | 游戏玩法 |开始答题 | 开始答题 |跳过 | 跳过 |退出 | 退出