rampatra / jbot

Make Slack and Facebook Bots in Java.
GNU General Public License v3.0
1.2k stars 350 forks source link

not able to start a conversation #75

Open gclouds opened 7 years ago

gclouds commented 7 years ago

only two methods I have created,it calls succesfully 'startATest' method and it never calls 'confirmStoreCode' method.

   @Controller(pattern = "(start a test)", next = "confirmStoreCode",events = { EventType.DIRECT_MESSAGE})
    public void startATest(WebSocketSession session, Event event) {
        try {
            reply(session, event, new Message("Cool! Currently I can run test suite for a Store code, please tell me the Store Code."));
            startConversation(event, "confirmStoreCode");   // start conversation
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    @Controller
    public void confirmStoreCode(WebSocketSession session, Event event) {

        logger.info("Job confirmStoreCode");
        try {
            String storeCode = CommonHelper.toString(event.getText()).trim().toUpperCase();
            List<GenericTestCase> testCases = testCase.findByStoreCode(storeCode);

            // testCases = testCases.subList(0, 2);
            if (testCases.size()>0) {
                reply(session, event, new Message("Your Store Code " + event.getText() +
                        "Found test cases. Would you like to run it?"));
            } else {
                reply(session, event, new Message("Sorry no test case found" + event.getText()));
                stopConversation(event); 
            }
            nextConversation(event);
        } catch (Exception e) {
            logger.error("Exception in completing the test suite", e);
            reply(session, event, new Message("Your meeting is set at " + event.getText() +
                    ". Would you like to repeat it tomorrow?"));
        }

    }
rampatra commented 7 years ago

Can you please call the startConversation() method at the beginning and then the reply() method?

gclouds commented 7 years ago

I tried with keeping it on beginning also. still same issue :(