打印原始对话流量查询结果履行消息

发布于 2025-02-11 11:31:34 字数 1076 浏览 0 评论 0原文

我有以下DialogFlow默认值和Facebook响应的意图。

我有一个简单的幻影应用程序,该应用程序在DialogFlowapi对象上调用检测符,该对象返回带有查询结果的响应。我想将原始履行消息打印到控制台上。

...
    var response = await df.detectIntent(request, sessionPath);

List<GoogleCloudDialogflowV2IntentMessage> payloads = response.queryResult.fulfillmentMessages;
debugPrint("Got response length: ${payloads.length}");
payloads.forEach((element) => debugPrint(element.payload.toString()));

我得到以下控制台输出:

flutter: Got response length: 3
flutter: {text: this is some default text!, replies: [default option 1, default option 2]}
flutter: null
flutter: {replies: [default option 1, default option 2], text: this is some default text!}

有3个响应,其中2个响应正确打印。它不会打印Facebook响应的快速答复。

I have the following DialogFlow default and Facebook responses for an intent.
default response
facebook response

I have a simple Flutter app that calls detectIntent on a DialogflowAPI object that returns a response with query result. I want to print the raw fulfilment messages to console.

...
    var response = await df.detectIntent(request, sessionPath);

List<GoogleCloudDialogflowV2IntentMessage> payloads = response.queryResult.fulfillmentMessages;
debugPrint("Got response length: ${payloads.length}");
payloads.forEach((element) => debugPrint(element.payload.toString()));

I get the below console output:

flutter: Got response length: 3
flutter: {text: this is some default text!, replies: [default option 1, default option 2]}
flutter: null
flutter: {replies: [default option 1, default option 2], text: this is some default text!}

There are 3 responses, of which 2 are printed correctly. It does not print the quick replies part of the facebook response.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入怼 2025-02-18 11:31:34

每个googleCloudDialogFlowV2intentMessage具有有效载荷成员,它是JSON的map&lt; string,object?&gt;。您可以打印出来:

payloads.forEach((element) => debugPrint(element.payload.toString()));

或者,

还有一个tojson()方法,它可能会为您提供更多完整的信息。您也可以尝试打印它:

payloads.forEach((element) => debugPrint(jsonEncode(element.toJson())));

注:您需要包括导入'dart:convert';

Each GoogleCloudDialogflowV2IntentMessage has a payload member, which is a json-like Map<String, Object?>. You can print this out:

payloads.forEach((element) => debugPrint(element.payload.toString()));

Alternatively

There is also a toJson() method, which might give you more complete information. You can try printing that as well:

payloads.forEach((element) => debugPrint(jsonEncode(element.toJson())));

Note: you'll need to include import 'dart:convert';.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文