Flutter dialogflow 在查询中不接受 space

Flutter dialogflow not accepting space in query

Flutter dialogflow 不接受 space 查询。提供给 dialogflow 客户端的查询不接受 space。例如 "Hi" 是允许的,但 "Hi " 是不允许的,因为它有 space。同样,它只接受一个词而不是句子(因为它有 spaces 的词)。需要帮助。

import 'package:flutter_dialogflow/flutter_dialogflow.dart'; 
 void Response(query) async {
    _textController.clear();
    print("BLB calling $query= ${query.toString().trim()}");
    Dialogflow dialogflow =Dialogflow(token: "**api_key**");
    AIResponse response = await dialogflow.sendQuery(query).catchError((error){print("BLB $error ");});
    print("BLB called ${response.getStatus.getCode}");
    ChatMessage message = new ChatMessage(
      text: response.getMessageResponse(),
      name: "Eva the Bot",
      type: false,
    );
    //Tts.speak(response.getMessageResponse());
    setState(() {
      _messages.insert(0, message);
    });
  }

错误信息:FormatException: Context name should contain only Latin letters (a-z A-Z), digits (0-9), underscore (_), and hyphen (-). Code: 400 对话流在控制台中完美运行(右侧 'Try it now')。:(

最好的解决方案是使用API V2,它没有这个问题。 使用 this tutorial 进行设置。

无论如何你都必须这样做,因为 API V1 will be shut down on October 23, 2019