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 fr.paris.lutece.plugins.botpress.service;
35
36 import fr.paris.lutece.plugins.botpress.business.BPBot;
37 import fr.paris.lutece.plugins.chatbot.business.BotPost;
38 import fr.paris.lutece.plugins.chatbot.service.bot.AbstractChatBot;
39 import java.util.ArrayList;
40 import java.util.List;
41 import java.util.Locale;
42
43
44
45
46 public final class BotInstance extends AbstractChatBot
47 {
48
49
50 private String _strBotApiEntryPointUrl;
51 private String _strErrorMessage;
52
53
54
55
56
57
58
59 public BotInstance( BPBot bot )
60 {
61 super( );
62
63 setKey( bot.getBotKey( ) );
64 setName( bot.getName( ) );
65 setDescription( bot.getDescription( ) );
66 List listLanguages = new ArrayList<>( );
67 listLanguages.add( bot.getLanguage( ) );
68 setListAvailableLanguages( listLanguages );
69 setAvatarUrl( bot.getAvatarUrl( ) );
70 setStandalone( bot.getIsStandalone( ) != 0 );
71 setWelcomeMessage( bot.getWelcomeMessage( ) );
72 setAvatarRendererKey( bot.getAvatarRendererKey( ) );
73 _strBotApiEntryPointUrl = ConverseService.getBotApiEntryPointUrl( bot.getBotPressKey( ), bot.getServerUrl( ), bot.getApiVersion( ) );
74 _strErrorMessage = bot.getErrorMessage( );
75
76 }
77
78
79
80
81
82
83 public String getBotApiEntryPointUrl( )
84 {
85 return _strBotApiEntryPointUrl;
86 }
87
88
89
90
91
92
93
94 public void setBotApiEntryPointUrl( String strBotApiEntryPointUrl )
95 {
96 _strBotApiEntryPointUrl = strBotApiEntryPointUrl;
97 }
98
99
100
101
102 @Override
103 public List<BotPost> processUserMessage( String strMessage, String strConversationId, Locale locale )
104 {
105 return ConverseService.getBotResponse( strMessage, strConversationId, _strBotApiEntryPointUrl, _strErrorMessage, locale );
106 }
107
108
109
110
111
112
113
114 @Override
115 public void reset( String strConversationId )
116 {
117
118 }
119
120 }