我该如何用JSON响应来自Java的Dialogflow的套接字Webhook Post请求进行响应?

时间:2019-01-02 23:05:46

标签: java dialogflow dialogflow-fulfillment

我当前正在尝试创建本地服务器,以便可以使用Dialogflow与我的Google home通信。现在,我从中接收到POST JSON请求,但是我尝试使用已制定的JSON响应来响应这些请求。有什么简单的方法可以做到这一点吗?这是我的主班。 Listener类仅将Char输入转换为完整的String。评分器类制定了一个我想发送回Dialogflow的响应。

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class Init {

    public static void main(String args[]) throws IOException {
      int port = 8087;

      String sentence = "";

          ServerSocket server = new ServerSocket(port);
          System.out.println("Server starting on " + port + "...");



        while(true) {
            Socket client = server.accept();
            sentence = Listener.listener(client);
            sentence = sentence.toLowerCase();
            Scorer.scorer(sentence);
            System.out.println(sentence);


        }

     }
 }

0 个答案:

没有答案