0

Hi am trying to build a Slack bot that asks questions and takes answers, how do I achieve the below use case

My use case:
User: @MyBot start
Bot: question 1 (respond in threads or respond to channel)
User: Answer 1 (take this answer)
Bot: ask question 2
User: Answer 2 (take this answer)
Bot: you scored 100 %

below code responds in the thread using ts, am okay to start a conversation in the channel or thread (preferred but not required)

so far I achieved following

app.event(AppMentionEvent.class, (payload, ctx) -> {
    AppMentionEvent event = payload.getEvent();
    String type = event.getText().substring(event.getText().indexOf('>') + 1);
    if (type.equals("start")) {
        ChatPostMessageResponse message = ctx.client()
                .chatPostMessage(r -> r.channel(event.getChannel()).threadTs(event.getTs())// event.getThreadTs() is null here
                        .text("question 1"));
    } else {
        ctx.logger.info("add it latter");
    }
    return ctx.ack();
});

am stuck on how to take users' response and unable to find relavent event, kindly share your knowledge

0 Answers0