Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conversation is not invoked on "setup meeting" #163

Open
rajeshbtlit opened this issue Dec 23, 2019 · 1 comment
Open

conversation is not invoked on "setup meeting" #163

rajeshbtlit opened this issue Dec 23, 2019 · 1 comment

Comments

@rajeshbtlit
Copy link

Thanks for your efforts, I am trying to use the start conversation , when we type "start meeting" the
@controller(pattern = "(setup meeting)", next = "confirmTiming")
public void setupMeeting(WebSocketSession session, Event event) { is not invoked .

But
@controller(events = {EventType.DIRECT_MENTION, EventType.DIRECT_MESSAGE})
public void onReceiveDM(WebSocketSession session, Event event) {
is invoked.

Could you pease help.

Thanks in advance

@rajeshbtlit rajeshbtlit changed the title Start conversation is not invoked on "setup meeting" conversation is not invoked on "setup meeting" Dec 23, 2019
@Ronin3502
Copy link

The main reason the problem occurred since the condition is always true, and the type of event would be set as DIRECT_MESSAGE ( I don't know why : ( ,

So, I change the eventType in SlackBot.java .

I am not sure if my method towards this issue is proper.
the following are the modifications on Slackbot.java:
First, I added "events = EventType.DIRECT_MESSAGE" to each collector in the conversation.
Second, I added some text check in each function.

The code of the conversation about setup meeting is like the following:

    @Controller(events = EventType.DIRECT_MESSAGE, pattern = "(setup meeting)", next = "confirmTiming")
    public void setupMeeting(WebSocketSession session, Event event) {
    	if(event.getText().contains("meeting")){
        	startConversation(event, "confirmTiming");   // start conversation
        	reply(session, event, "Cool! At what time (ex. 15:30) do you want me to set up the meeting?");
    	}
    }

    /**
     * This method will be invoked after {@link SlackBot#setupMeeting(WebSocketSession, Event)}.
     *
     * @param session
     * @param event
     */
    @Controller(events = EventType.DIRECT_MESSAGE, next = "askTimeForMeeting")
    public void confirmTiming(WebSocketSession session, Event event) {
    	if(event.getText().contains(":")) {
        	reply(session, event, "Your meeting is set at " + event.getText() +
                	". Would you like to repeat it tomorrow?");
        	nextConversation(event);    // jump to next question in conversation
        }
    }

    /**
     * This method will be invoked after {@link SlackBot#confirmTiming(WebSocketSession, Event)}.
     *
     * @param session
     * @param event
     */
    @Controller(events = EventType.DIRECT_MESSAGE, next = "askWhetherToRepeat")
    public void askTimeForMeeting(WebSocketSession session, Event event) {
        if (event.getText().contains("yes")) {
            reply(session, event, "Okay. Would you like me to set a reminder for you?");
            nextConversation(event);    // jump to next question in conversation  
        } else if(event.getText().contains("no")) {
            reply(session, event, "No problem. You can always schedule one with 'setup meeting' command.");
            stopConversation(event);    // stop conversation only if user says no
        }
    }

    /**
     * This method will be invoked after {@link SlackBot#askTimeForMeeting(WebSocketSession, Event)}.
     *
     * @param session
     * @param event
     */
    @Controller(events = EventType.DIRECT_MESSAGE)
    public void askWhetherToRepeat(WebSocketSession session, Event event) {
        if (event.getText().contains("yes")) {
            reply(session, event, "Great! I will remind you tomorrow before the meeting.");
        } else if(event.getText().contains("no")){
            reply(session, event, "Okay, don't forget to attend the meeting tomorrow :)");
        }
        stopConversation(event);    // stop conversation
    }

Hope my code can satisfy your expectation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants