ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### 3.2.16 灯谜猜猜 #### (1)功能说明 灯谜猜猜是一款有趣的益智游戏。游戏有三关,难度递增。答对一题,就能拿到一盏花灯。每关10道题,拿到6盏以上(含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=竹子 返回结果 ``` { code: 0, msg: "ok", result: { _text: "竹子", msg_id: "3589a168-f712-4033-8e39-bbdbdf78666a", intents: [{ parameters: { text: "竹子", service: "lanternRiddle" }, action: "玩猜灯谜", name: "玩猜灯谜", result: { code: 200, response: { code: 0, msg: "成功", result: { rank: "1", questionCount: "1", rightAnswerCountCurrentRound: "1", questionAndAnswer: { answer: "玉米", question: "一物生得真奇怪,腰里长出胡子来,拔掉胡子剥开看,露出牙齿一排排。 (打一植物)", id: 1749 }, currentDengMiAnswerCount: 0, gameContinue: true, lastAnswerIsTrue: "true" } }, text: "答对了,赞一个!送你1盏花灯。下一题:一物生得真奇怪,腰里长出胡子来,拔掉胡子剥开看,露出牙齿一排排。 (打一植物)", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: "答对了,真棒!送你1盏花灯。下一题:一物生得真奇怪,腰里长出胡子来,拔掉胡子剥开看,露出牙齿一排排。 (打一植物)" } }, { type: "dialog", property: { text: "答对了,好厉害!送你1盏花灯。下一题:一物生得真奇怪,腰里长出胡子来,拔掉胡子剥开看,露出牙齿一排排。 (打一植物)", emotion: "happy" } }, { type: "dingdang.display.directive", payload: { text: "答对了,真棒!送你1盏花灯。下一题:一物生得真奇怪,腰里长出胡子来,拔掉胡子剥开看,露出牙齿一排排。 (打一植物)", type: "Display.RenderTemplate", token: "dengmicaicaiplay", template: { type: "NewsBodyTemplate", textContent: { title: "", description: "一物生得真奇怪,腰里长出胡子来,拔掉胡子剥开看,露出牙齿一排排。 (打一植物)" }, backgroundImage: { contentDescription: "", source: { url: "http://image.ruyi.ai/dingdang/1108dingdang-猜灯谜.jpg" } }, backgroundAudio: { source: { url: "" } }, url: "" } } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "e0a69301-6ab1-496d-b5ba-d743595e7d22", id: "e8be266a-0c2c-4ae6-a245-e4179229a434" }], meta_process_milliseconds: 264 } } ``` 请求示例 (跳过) http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=跳过 返回结果 ``` { code: 0, msg: "ok", result: { _text: "不知道", msg_id: "a56ba146-ec9a-45b8-8b4b-573ec8e4c2ee", intents: [{ parameters: { text: "", any1: "", jump: "1", service: "lanternRiddle" }, action: "跳过", name: "跳过", result: { code: 200, response: { code: 0, msg: "成功", result: { rank: "1", questionCount: "2", rightAnswerCountCurrentRound: "1", questionAndAnswer: { answer: "荷花", question: "一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", id: 1807 }, currentDengMiAnswerCount: 0, gameContinue: true, lastAnswerIsTrue: "false", lastAnswer: "玉米" } }, text: "正确答案是玉米。下一题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: "正确答案是玉米。下一题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)" } }, { type: "dialog", property: { text: "好的,已跳过。答案是玉米。下一题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", emotion: "positive" } }, { type: "dingdang.display.directive", payload: { text: "好的,已跳过。答案是玉米。下一题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", type: "Display.RenderTemplate", token: "dengmicaicaicidian", template: { type: "NewsBodyTemplate", textContent: { title: "", description: "一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)" }, backgroundImage: { contentDescription: "", source: { url: "http://image.ruyi.ai/dingdang/1108dingdang-猜灯谜.jpg" } }, backgroundAudio: { source: { url: "" } }, url: "" } } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "e0a69301-6ab1-496d-b5ba-d743595e7d22", id: "44f0da7b-456c-408c-bd97-186606a783e8" }], meta_process_milliseconds: 334 } } ``` 请求示例 (重复) http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=重复 返回结果 ``` { code: 0, msg: "ok", result: { _text: "重复", msg_id: "f9cb705c-88b6-4e2b-8c91-91171cf84255", intents: [{ parameters: { service: "lanternRiddle" }, action: "猜灯谜-重复", name: "重复", result: { code: 200, response: { code: 0, msg: "成功", result: { rank: "1", questionCount: "2", rightAnswerCountCurrentRound: "1", questionAndAnswer: { answer: "荷花", question: "一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", id: 1807 }, currentDengMiAnswerCount: 0, gameContinue: true, lastAnswerIsTrue: "false", lastAnswer: "玉米", theFirstCharacter: "荷" } }, text: "请听题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: "请听题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)" } }, { type: "dialog", property: { text: "请听题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", emotion: "calm" } }, { type: "dingdang.display.directive", payload: { text: "请听题:一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", type: "Display.RenderTemplate", token: "dengmicaicairepeat", template: { type: "NewsBodyTemplate", textContent: { title: "", description: "一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)" }, backgroundImage: { contentDescription: "", source: { url: "http://image.ruyi.ai/dingdang/1108dingdang-猜灯谜.jpg" } }, backgroundAudio: { source: { url: "" } }, url: "" } } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "e0a69301-6ab1-496d-b5ba-d743595e7d22", id: "bdfac779-ef8c-4b0b-9d12-b6ee9ca0434d" }], meta_process_milliseconds: 403 } } ``` 请求示例 (退出) http://api.ruyi.ai/ruyi-api/v1/message?app_key=APP_KEY&user_id=user0&q=退出 返回结果 ``` { code: 0, msg: "ok", result: { _text: "退出", msg_id: "50921777-db85-48df-bdca-91666f38f659", intents: [{ parameters: { text: "1", 退出: "结束", service: "lanternRiddle" }, action: "玩猜灯谜", name: "退出如意技能", result: { code: 200, response: { code: 0, msg: "成功", result: { rank: "1", questionCount: "2", rightAnswerCountCurrentRound: "1", questionAndAnswer: { answer: "荷花", question: "一个小姑娘,生在水中央,身穿粉红衫,坐在绿船上。(打一植物)", id: 1807 }, currentDengMiAnswerCount: "1", gameContinue: true, lastAnswerIsTrue: "false", lastAnswer: "玉米" } }, text: "你在灯谜猜猜的第一关拿到了1盏花灯,再接再厉哦", type: "dialog" }, outputs: [{ type: "wechat.text", property: { text: "你在灯谜猜猜的第一关拿到了1盏花灯,再接再厉哦" } }, { type: "dialog", property: { text: "你在灯谜猜猜的第一关拿到了1盏花灯,再接再厉哦", emotion: "calm" } }, { type: "dingdang.display.directive", payload: { text: "已为你退出技能。下次玩跟我说“猜灯谜”", type: "Display.RenderTemplate", token: "dengmicaicaiquit", template: { type: "NewsBodyTemplate", textContent: { title: "", description: "已为你退出技能。下次玩跟我说“猜灯谜”" }, backgroundImage: { contentDescription: "", source: { url: "http://image.ruyi.ai/dingdang/1108dingdang-猜灯谜.jpg" } }, backgroundAudio: { source: { url: "" } }, url: "" } } } ], score: "1.0", scoreColor: "c4", is_match: 1, skill_id: "e0a69301-6ab1-496d-b5ba-d743595e7d22", id: "75622406-817c-470f-8144-38ac49e4ae93" }], meta_process_milliseconds: 93 } } ``` 详细参数说明 名称 |类型| 说明 ---- |---- |---- | service| String| 服务名称 lastAnswer| Boolean |判断是否为正确答案,是则为 true question| String |当前问题内容 answer |String |当前答案 theFirstCharacter |String |提示答案第一个字 gameContinue |String |游戏是否继续 answer |String |当前这一轮的答案 rank |String |第几关 currentDengMiAnswerCount | Integer |当前问题回答次数 rightAnswerCountCurrentRound |Integer |回答正确数 questionCount |Integer |所回答的问题总数 指令清单 指令名称| 范例 ---- |---- 唤醒 |灯谜猜猜 开始游戏| 开始 玩游戏| 竹子 重复| 没听清 跳过 |跳过 退出| 不玩了