0
votes

I'm setting up a chat bot in JHIPSTER & Dialogflow. but I keep getting errors when I execute my code.

I have created a class called DetectIntent with the code for DetectIntent provided by DialogFlow v2, and a REST api that receives messages from users and then I call the DetectIntent class to understand what the user wants to say.

NOTE: I am behind a proxy of the company I work at.


import com.google.api.client.util.Maps;
import com.google.cloud.dialogflow.v2.DetectIntentResponse;
import com.google.cloud.dialogflow.v2.QueryInput;
import com.google.cloud.dialogflow.v2.QueryResult;
import com.google.cloud.dialogflow.v2.SessionName;
import com.google.cloud.dialogflow.v2.SessionsClient;
import com.google.cloud.dialogflow.v2.TextInput;
import com.google.cloud.dialogflow.v2.TextInput.Builder;


import java.util.List;
import java.util.Map;


/**
 * DialogFlow API Detect Intent sample with text inputs.
 */
public class DetectIntent {
    public static Map<String, QueryResult> detectIntentTexts(
        String projectId,
        List<String> texts,
        String sessionId,
        String languageCode) throws Exception {
        Map<String, QueryResult> queryResults = Maps.newHashMap();
        // Instantiates a client
        try (SessionsClient sessionsClient = SessionsClient.create()) {
            // Set the session name using the sessionId (UUID) and projectID (my-project-id)
            SessionName session = SessionName.of(projectId, sessionId);
            System.out.println("Session Path: " + session.toString());

            // Detect intents for each text input
            for (String text : texts) {
                // Set the text (hello) and language code (en-US) for the query
                TextInput.Builder textInput = TextInput.newBuilder().setText(text).setLanguageCode(languageCode);

                // Build the query with the TextInput
                QueryInput queryInput = QueryInput.newBuilder().setText(textInput).build();

                // Performs the detect intent request
                DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);

                // Display the query result
                QueryResult queryResult = response.getQueryResult();

                System.out.println("====================");
                System.out.format("Query Text: '%s'\n", queryResult.getQueryText());
                System.out.format("Detected Intent: %s (confidence: %f)\n",
                    queryResult.getIntent().getDisplayName(), queryResult.getIntentDetectionConfidence());
                System.out.format("Fulfillment Text: '%s'\n", queryResult.getFulfillmentText());

                queryResults.put(text, queryResult);
            }
        }
        return queryResults;
    }
}
@RestController
@RequestMapping("/api")
public class ConversationExchange {


    public ConversationExchange()
    {

    }



    // Receive Messages Web Hook
    @PostMapping(path="/whatsapp/hook")
    public void TwilioWebHook(@RequestParam Map<String, String> map) throws Exception {

        System.out.println("************************************************");
        System.out.println("************************************************");
        System.out.println("- DATA : " + map );
        System.out.println("- SMS ID : " + map.get("SmsSid").toString());
        System.out.println("- SENDER : " + map.get("From").toString());
        System.out.println("- RECEIVER : " + map.get("To").toString());
        System.out.println("- MESSAGE : " + map.get("Body").toString());
        System.out.println("- STATUS : " + map.get("SmsStatus").toString());
        System.out.println("- MESSAGE SID : " + map.get("MessageSid").toString());
        System.out.println("- Account SID : " + map.get("AccountSid").toString());
        System.out.println("************************************************");
        System.out.println("************************************************");

        List<String> list = new ArrayList<String>(Arrays.asList(map.get("Body").split(" ")));

        // Detect Intent From Message

        String session = UUID.randomUUID().toString();
        DetectIntent detectIntent = new DetectIntent();
        String response = detectIntentTexts("agent...", list, session,"fr-FR").toString();

        System.out.println("----> INTENT DETECTED : " + response );
        // SEND RESPONSE
    }

}

I excepted to get the intent detected but what I get multiple errors in the console.

i.g.n.s.io.grpc.netty.GrpcSslContexts    : Conscrypt class not found. Not using Conscrypt

i.g.n.s.i.n.u.i.NativeLibraryLoader      : Unable to load the library 'io_grpc_netty_shaded_netty_tcnative_windows_x86_64', trying other loading mechanism.

i.g.n.s.i.n.u.i.NativeLibraryLoader      : io_grpc_netty_shaded_netty_tcnative_windows_x86_64 cannot be loaded from java.libary.path, now trying export to -Dio.netty.native.workdir:..

Couldn't load full implementation for TagsComponent, now trying to load lite implementation.

io.opencensus.tags.Tags                  : Couldn't load lite implementation for TagsComponent, now using default implementation for TagsComponent.

io.opencensus.stats.Stats                : Couldn't load full implementation for StatsComponent, now trying to load lite implementation.

io.opencensus.stats.Stats                : Couldn't load lite implementation for StatsComponent, now using default implementation for StatsComponent.

io.opencensus.trace.Tracing              : Couldn't load full implementation for TraceComponent, now trying to load lite implementation.

io.opencensus.trace.Tracing              : Couldn't load lite implementation for TraceComponent, now using default implementation for TraceComponent.

io.grpc.Context                          : Storage override doesn't exist. Using default

1
are these really errors? Looks like DEBUG / INFO / WARN messages to me. - Alexander
it's DEBUG but the output am looking for isn't generated. System.out.println("----> INTENT DETECTED : " + response ); - BarNation
but you wrote "but what I get multiple errors in the console" - that's missleading. Would you please edit your post to clarify this? - Alexander

1 Answers

0
votes

Fixed it, the issue was the proxy, I had to set system variables to support the proxy.