-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathChooseScene.java
65 lines (59 loc) · 2.37 KB
/
ChooseScene.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.greenapi.chatbot.examples.full;
import com.greenapi.chatbot.pkg.Scene;
import com.greenapi.chatbot.pkg.state.State;
import com.greenapi.client.pkg.models.Contact;
import com.greenapi.client.pkg.models.Option;
import com.greenapi.client.pkg.models.notifications.MessageWebhook;
import java.util.ArrayList;
public class ChooseScene extends Scene {
@Override
public State processIncomingMessage(MessageWebhook incomingMessage, State currentState) {
var text = getText(incomingMessage);
if (text.isEmpty()) {
answerWithText(incomingMessage, "Please send a text message!");
return currentState;
}
switch (text.get()) {
case "1" -> {
answerWithText(incomingMessage, "Hi! This is answerWithText!");
return currentState;
}
case "2" -> {
answerWithText(incomingMessage, "Send me the link on File:");
return activateNextScene(currentState, new InputLinkScene());
}
case "3" -> {
var options = new ArrayList<Option>();
options.add(new Option("Red"));
options.add(new Option("Blue"));
options.add(new Option("Green"));
options.add(new Option("Pink"));
answerWithPoll(incomingMessage, "choose color", options, false);
return currentState;
}
case "4" -> {
answerWithLocation(incomingMessage, "Home", "Cdad. de La Paz 2969, Buenos Aires", -34.5553558, -58.4642510);
return currentState;
}
case "5" -> {
var contact = Contact.builder()
.firstName("first")
.lastName("last")
.middleName("middle")
.company("Green API")
.phoneContact(11111111111L)
.build();
answerWithContact(incomingMessage, contact);
return currentState;
}
case "6" -> {
answerWithText(incomingMessage, "Goodbye!");
return activateStartScene(currentState);
}
default -> {
answerWithText(incomingMessage, "Please send numbers - 1, 2, 3, 4, 5 or 6");
return currentState;
}
}
}
}