-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBotStarter.java
34 lines (26 loc) · 1.1 KB
/
BotStarter.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
package com.greenapi.demoChatbot;
import com.greenapi.chatbot.pkg.BotFactory;
import com.greenapi.client.pkg.models.request.InstanceSettingsReq;
import com.greenapi.demoChatbot.scenes.Start;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class BotStarter {
public static void main(String[] args) {
var context = SpringApplication.run(BotStarter.class, args);
var botFactory = context.getBean(BotFactory.class);
var startScene = context.getBean(Start.class);
var instanceId = "{InstanceId}";
var token = "{TokenId}";
var bot = botFactory.createBot(instanceId, token);
bot.greenApi.account.setSetting(InstanceSettingsReq.builder()
.incomingWebhook("yes")
.outgoingMessageWebhook("yes")
.outgoingAPIMessageWebhook("yes")
.pollMessageWebhook("yes")
.markIncomingMessagesReaded("yes")
.build());
bot.setStartScene(startScene);
bot.startReceivingNotifications();
}
}