# 通过插件调取 NLU 结果
# 初始化
文档内插件版本号,仅做示例参考,插件最新版本,以此处为准
{
"pages": [
"pages/index/index"
],
"plugins": {
"chatbot": {
"version": "1.2.23",
"provider": "wx8c631f7e9f2465e1"
}
},
"requiredBackgroundModes": [
"audio"
],
"sitemapLocation": "sitemap.json"
}
var plugin = requirePlugin("chatbot");
App({
onLaunch: function () {
plugin.init({
appid: "P5Ot9PHJDechCYqDFAW1AiK6OtG3Ja", //小程序示例账户,仅供学习和参考
openid: "", //用户的openid,非必填,建议传递该参数
success: () => {}, //非必填
fail: (error) => {}, //非必填
});
},
});
# 调用对话接口
plugin.send({
query: "你好",
success: (res) => {
console.log(res);
},
fail: (error) => {},
});
# NLU 结果
{
"ans_node_id": 6666,
"ans_node_name": "天气服务",
"answer": "北京今天小雨,温度18到29度,当前温度27度,空气质量轻度污染,今天有雨,略微偏热,注意衣物变化。",
"answer_open": 1,
"answer_type": "text",
"article": "",
"bid_stat": {
"curr_time": "20190826-16:34:56",
"err_msg": "",
"latest_time": "20190826-16:34:56",
"latest_valid": true,
"up_ret": 0
},
"confidence": 1,
"create_time": "1566810973035",
"dialog_status": "COMPLETE",
"from_user_name": "o9U-85tEZToQxIF8ht6o-KkagxO0",
"intent_confirm_status": "",
"list_options": false,
"msg": [
{
"ans_node_id": 6666,
"ans_node_name": "天气服务",
"article": "",
"confidence": 1,
"content": "北京今天小雨,温度18到29度,当前温度27度,空气质量轻度污染,今天有雨,略微偏热,注意衣物变化。",
"debug_info": "",
"list_options": false,
"msg_type": "text",
"resp_title": "天气服务",
"status": "CONTEXT_FAQ"
}
],
"ret": 0,
"skill_id": "",
"skill_type": "",
"slot_info": [
{
"date": "{\"type\":\"DT_ORI\",\"date_ori\":\"今天\",\"date\":\"2019-08-26\",\"date_lunar\":\"2019-08-26\",\"week\":\"1\",\"slot_content_type\":\"2\",\"modify_times\":\"0\"}"
},
{
"from_loc": "{\"type\":\"LOC_CHINA_CITY\",\"country\":\"中国\",\"city\":\"北京\",\"city_simple\":\"北京\",\"loc_ori\":\"北京\",\"slot_content_type\":\"2\",\"modify_times\":\"1\"}"
}
],
"slots_info": [
{
"confirm_status": "NONE",
"end": 0,
"entity_type": "",
"norm": "2019-08-26",
"norm_detail": "",
"slot_name": "date",
"slot_value": "{\"type\":\"DT_ORI\",\"date_ori\":\"今天\",\"date\":\"2019-08-26\",\"date_lunar\":\"2019-08-26\",\"week\":\"1\",\"slot_content_type\":\"2\",\"modify_times\":\"0\"}",
"start": 0
},
{
"confirm_status": "NONE",
"end": 6,
"entity_type": "LOC_CHINA_CITY",
"norm": "{\"type\":\"LOC_CHINA_CITY\",\"country\":\"中国\",\"city\":\"北京\",\"city_simple\":\"北京\",\"loc_ori\":\"北京\"}",
"norm_detail": "",
"slot_name": "from_loc",
"slot_value": "{\"type\":\"LOC_CHINA_CITY\",\"country\":\"中国\",\"city\":\"北京\",\"city_simple\":\"北京\",\"loc_ori\":\"北京\",\"slot_content_type\":\"2\",\"modify_times\":\"1\"}",
"start": 0
}
],
"status": "CONTEXT_FAQ",
"title": "天气服务",
"to_user_name": "10808"
}