简体   繁体   English

从 Watson Discovery 搜索结果中获取相关字段作为 Watson 助手响应

[英]Obtaining relevant fields from Watson Discovery search results as Watson assistant response

I am using watson assistant webhooks to call a watson discovery query action.我正在使用 watson 助手 webhook 来调用 watson 发现查询操作。 Using $webhook_result_1.passages , I'm getting all the passage fields.使用$webhook_result_1.passages ,我得到了所有的段落字段。 I want the assistant response as the passage_text field only.我希望助手响应仅作为passage_text字段。 I have tried everything like $webhook_result_1.passages.passage_text , $webhook_result_1.passages[0].passage_text but nothing seems to work.我已经尝试过$webhook_result_1.passages.passage_text$webhook_result_1.passages[0].passage_text类的所有方法,但似乎没有任何效果。

{
"matching_results": 14,
"session_token": "1_xvrscQ9w1x7chIp2_HWOk4wS8K",
"passages": [
    {
        "document_id": "3a5efee70d8cc9d70e2b94d22c15e2d1_8",
        "passage_score": 8.335406752877208,
        "passage_text": "If you have a furnace or boiler installed: 1. Select the heating menu. 2. Configure the heater type:  Furnace: Optimizes ecobee3 for systems using forced air  Boiler: Optimizes your ecobee3 for systems using radiators or in-floor heat. 3.",
        "start_offset": 0,
        "end_offset": 240,
        "field": "text"
    },

See Expression language methods请参阅表达式语言方法

For a context variable named testarray with value [{"text":"value"},{"text":"2"}] in the dialog response text I can use this to output the 'text' property from the first object:对于名为testarray的上下文变量,对话框响应文本中的值为[{"text":"value"},{"text":"2"}]我可以将其用于 output 的第一个 object 的 'text' 属性:

 <? context.testarray.get(0).get("text").getAsString() ?>

You may therefore need:因此,您可能需要:

Passage is : <?context.webhook_result_1.passages.get(0).get("passage_text").getAsString() ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM