Genesys CTI User Forum > Genesys-related Development
ERROR [BotsManager] - ChatBotFactory service not found in jar
Rajnish@49:
Hello All,
I am creating a ChatBot using NetBeans 11.1. I am getting this error in DMS while loading of Bot.
ERROR [BotsManager] - ChatBotFactory service not found in jar AmazonLexRestAccess_V1-1-jar-with-dependencies.jar
ERROR [BotsManager] - Failed to load bot plugin from: AmazonLexRestAccess_V1-1-jar-with-dependencies.jar
Below is the code:-
AmazonLexRestAccess_V1.java
public class AmazonLexRestAccess_V1 implements ChatBot {
private ChatBotPlatform cbpInstance;
private Logger logger; // bot-session aware logger
private GenesysChatSession session;
@Override
public void setCbpInstance(ChatBotPlatform cbpInstance) {
this.cbpInstance = cbpInstance;
this.logger = cbpInstance.getLogger();
}
@Override
public void onCommandStart(GenesysChatSession session, int eventJoinedId, EspRequestParameters espParameters) {
// TODO to be implemented
this.session = session;
cbpInstance.sendMessage("Thank you for contact Thermo Fisher scientific!! How may i help you today?");
}
@Override
public void onCommandStop(StopReason reason, ChatEventInfo eventInfo, EspRequestParameters espParameters) {
// TODO to be implemented
}
@Override
public void onSessionActivity(ChatEventInfo eventInfo) {
// TODO to be implemented
ChatUserInfo originator = session.getParticipant(eventInfo.getUserId());
if (eventInfo.getEventType() == EventType.MESSAGE && originator.getUserType() != UserType.SYSTEM && originator.getUserType() != UserType.EXTERNAL)
{
if (eventInfo.getMessageText().matches("stop(:(keep_alive|force_close|close_if_no_agents))?"))
{
Action action = Action.KEEP_ALIVE;
String[] tokens = eventInfo.getMessageText().split(":");
if (tokens.length > 1)
{
action = Action.valueOf(tokens[1].toUpperCase());
}
// The bot decides to stop execution.
// The bot will be removed from chat session and discarded in BGS.
// If running in waiting mode, the interaction will be released in workflow.
// If the bot need to communicate something to workflow, it could invoke updateUserdata at this moment.
logger.info("Leaving chat session with after-action: " + action.name());
cbpInstance.leaveSession(action);
}
else
{
logger.info("Message Typed"+eventInfo.getMessageText());
cbpInstance.sendMessage(eventInfo.getMessageText());
AWSCredentials awsCreds=new BasicAWSCredentials("AccessKey","SecretKey");
//AmazonLexModelBuilding buildClient=AmazonLexModelBuildingClientBuilder
AmazonLexRuntime client= AmazonLexRuntimeClientBuilder.standard().withRegion(Regions.US_EAST_1).withCredentials(new AWSStaticCredentialsProvider(awsCreds)).build();
cbpInstance.sendMessage("Creds sent");
PostTextRequest postRequest=new PostTextRequest();
postRequest.setBotAlias("BookATrip_VFirst");
postRequest.setBotName("BookATrip_VFirst");
postRequest.setUserId("BotAccessRestAPI");
postRequest.setInputText(eventInfo.getMessageText());
cbpInstance.sendMessage("RequestMessage sent");
logger.info("Message Executed Till Build PostRequest");
PostTextResult textResult=client.postText(postRequest);
cbpInstance.sendMessage(textResult.getMessage());
logger.info("Echoing back message: " + eventInfo.getMessageText());
cbpInstance.sendMessage(eventInfo.getMessageText());
cbpInstance.sendMessage(eventInfo.getMessageText());
}
}
}
@Override
public void onCommandUpdate(EspRequestParameters espParameters) {
// TODO to be implemented
}
}
AmazonLexRestAccess_V1Factory
public class AmazonLexRestAccess_V1Factory implements ChatBotFactory {
private static final Logger LOG = LoggerFactory.getLogger(AmazonLexRestAccess_V1Factory.class);
public void initialize(KeyValueMap configuration) {
// TODO to be implemented
}
public void configurationUpdated(KeyValueMap configuration) {
// TODO to be implemented
}
public void shutdown() {
// TODO to be implemented
}
public ChatBot createChatBot(KeyValueMap espParameters, ChatInteractionInfo interactionInfo, BotCreationAttributes botCreationAttributes) {
return new AmazonLexRestAccess_V1();
}
@Override
public String getBotId() {
return "AmazonLexRestAccess_V1";
}
}
Kubig:
Did you add all your referenced libraries?
Rajnish@49:
Thanks Kubig...
I am very new to netBeans. so apologies...
While i Clean & Build. Only one Jar file is getting generated. And place the same in bots-repo.
Could you please help where would need to add those libraries?
I have added reference in my code and pom.xml as well.
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.lexruntime.AmazonLexRuntime;
import com.amazonaws.services.lexruntime.AmazonLexRuntimeClientBuilder;
import com.amazonaws.services.lexruntime.model.PostTextRequest;
import com.amazonaws.services.lexruntime.model.PostTextResult;
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.96</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-lex</artifactId>
<version>1.11.96</version>
<type>jar</type>
</dependency>
Kubig:
[quote]If your bot needs to use 3rd party libraries, you have the option to use maven-assembly-plugin and these libraries will be included into the resulting JAR file.[/quote]
Rajnish@49:
I am using maven-assembly-plugin to generate one jar file with all dependencies. DMS>>BGS throws error
2020-06-16T19:29:04,324 Std 45302 (CBP.platform) ERROR [BotsManager] - ChatBotFactory service not found in jar: LexV2-1.0-SNAPSHOT-jar-with-dependencies.jar
2020-06-16T19:29:04,324 Std 45302 (CBP.platform) ERROR [BotsManager] - Failed to load bot plugin from: LexV2-1.0-SNAPSHOT-jar-with-dependencies.jar
Navigation
[0] Message Index
[#] Next page
Go to full version