[go: up one dir, main page]

Skip to content

How to receive other notifications#

Installation#

Before you begin, you need to install the library and configure the bot; this process is described in detail here: How to import the library and configure your bot.

How to receive other notifications#

You can receive not only incoming messages, but also outgoing ones, as well as their statuses and any other types of web hooks. To do this, simply override the method you need.

In this scene, the bot receives all incoming messages and outputs them to the console. Other types of web hooks are ignored, they handlers have been added for clarity.

Link to example: event.

@Log4j2
public class EventStartScene extends Scene {

     // To process incoming messages.
     @Override
     public State processIncomingMessage(MessageWebhook incomingMessage, State currentState) {
         log.info(incomingMessage); // Display messages

         return currentState;
     }

     // To process outgoing messages
     @Override
     public State processOutgoingMessage(MessageWebhook outgoingMessage, State currentState) {
         return super.processOutgoingMessage(outgoingMessage, currentState);
     }

     // To process the statuses of outgoing messages
     @Override
     public State processOutgoingMessageStatus(OutgoingMessageStatus outgoingMessageStatus, State currentState) {
         return super.processOutgoingMessageStatus(outgoingMessageStatus, currentState);
     }

     // To process incoming calls
     @Override
     public State processIncomingCall(IncomingCall incomingCall, State currentState) {
         return super.processIncomingCall(incomingCall, currentState);
     }

     // To handle chat blocking
     @Override
     public State processIncomingBlock(IncomingBlock incomingBlock, State currentState) {
         return super.processIncomingBlock(incomingBlock, currentState);
     }
}

List of examples#

Description Example link
How to initialize an object BotStarterClassExample.java
Scene "Hello" BaseStartScene.java
Scene "Echo" EchoStartScene.java
How to receive other types of notifications EventStartScene.java
How to filter incoming messages FiltersStartScene.java
How to handle notification body MediaStartScene.java
How to work with bot state state
Example of a ready-made chat-bot full