Rehman
Rehman

Reputation: 1

Intents get changed with every input Watson Conversation(new name Watson Assistant)?

Once Application(Java Web app) has connected a conversation need to pass back the same context. But intents get changed(different nodes) every-time I send input(text to Watson), it doesn't stay in same intent.Why? Where am I making mistake?

public class TestConversation {

    public static void main(String[] args) {
        BufferedReader br = null;
        MessageResponse response = null;
        Map context = new HashMap();

        try {
            br = new BufferedReader(new InputStreamReader(System.in));

            String userName = br.readLine();
            // Add userName to context to be used by Conversation.
            context.put("userName", userName);

            while (true) {
                String input = br.readLine();
                response = conversationAPI(input, context);
                System.out.println("Watson Response: " + response.getText().get(0));
                context = response.getContext();
                System.out.println("———–");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static MessageResponse conversationAPI(String input, Map context) {
        ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2016_07_11);

        // Credentials of Workspace of Conversation
        service.setUsernameAndPassword("******************", "****************");
        MessageRequest newMessage = new MessageRequest.Builder().inputText(input).context(context).build();

        // Workspace ID of Conversation current workspace
        String workspaceId = "******************";
        MessageResponse response = service.message(workspaceId, newMessage).execute();
        return response;
    }

}

[Screenshot of code is also attached.][1]

[]: https://i.sstatic.net/bym6u.png

Upvotes: 0

Views: 54

Answers (1)

Simon O'Doherty
Simon O'Doherty

Reputation: 9359

Every input you send back to conversation will be analysed, then intents + entities are returned for what was written.

It should have no impact if your dialog flow is set up correctly to ignore it.

If you want to force it, you can send intents[] and entities[] in. It will disable checking and assume those are the found values.

Upvotes: 1

Related Questions