Skip to content

How to receive other notifications#


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

How to receive other notifications and process the notification body#

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 add a new handler to the scene or main function. Each scene can have multiple handlers.

Link to example: event.go.

package event

import cb ""

type StartScene struct {

func (s StartScene) Start(bot *cb.Bot) {
    bot.IncomingMessageHandler(func(notification *cb.Notification) {
        //Logic for processing incoming messages

    bot.OutgoingMessageHandler(func(notification *cb.Notification) {
        //Logic for processing outgoing messages

    bot.OutgoingMessageStatusHandler(func(notification *cb.Notification) {
        //Logic for processing outgoing message statuses

    bot.IncomingBlockHandler(func(notification *cb.Notification) {
        //Logic for processing chat blocking

    bot.IncomingCallHandler(func(notification *cb.Notification) {
        //Logic for processing incoming calls

    bot.DeviceInfoHandler(func(notification *cb.Notification) {
        //Logic for processing webhooks about the device status

    bot.StateInstanceChangedHandler(func(notification *cb.Notification) {
        //Logic for processing webhooks about changing the instance status

List of examples#

Description Link to example
How to initialize a handler base.go
How to initialize a scene baseScene.go
Scene "Echo" echo.go
How to receive other types of notifications event.go
How to filter incoming messages filter.go
How to work with bot state state.go
Example of a ready-made chat bot full.go