Receiving Events

In Bot Studio, whenever you activate a new bot, the system adds required event listeners to monitor pre-defined events. While Bot Studio can read all events happening to bots, it only acts on events that have been defined beforehand.

Responding to Events

For instance, when Discord bots receive a new message, Bot Studio only acts on it if your bot’s functional system has an event listener such as “Message Event” to handle messages. If you have not specified any event listeners for message events in your functional system, then Bot Studio will ignore the received event without acting on it.

Ignoring Events

Bot Studio will disregard any external event (events not generated by Bot Studio) in the following cases:

  1. If the bot is no longer valid (client destroyed, bot destroyed, bot offline, etc.). In this case, Bot Studio also destroys the bot client.
  2. If the bot’s functional system doesn’t have any defined event handler for the received event.
  3. If the event sender has been restricted by the bot’s action restrictions.

Event Processing

If the event is permitted to be read in Bot Studio, then Bot Studio will process the event through the following steps:

  1. Defining system’s global variables based on the received event.
  2. Creating a new engine to handle the received event.
  3. Adding the event to the bot’s events history.
  4. Registering the bot’s functional system into the created engine.
  5. Calling the engine to process the received event and its data based on the functional system.

Since a new engine is created to handle each new event received in Bot Studio, you do not need to restart your bot or perform any similar actions. Bot Studio handles received requests using the latest bot functional system. Here is how the engine processes the received event after it has been called:

  1. Starting the process from the event handler nodes such as “Message Event”.
  2. Running all action sockets that are not closed. For example, when using the “Match” node, if the “true” output must be activated, the “false” output won’t be activated.
  3. Using each node’s function. For example, when using the “Delay” node, this node will add a delay to the process. Note that Bot Studio only executes the next node whenever the recent node has been fully executed successfully.
  4. Executing all nodes until there are no active nodes.

Note that if a node’s execution process fails, subsequent nodes won’t get executed. However, when a node such as an API request receives an unsuccessful status, it doesn’t mean that the process failed. It means the response was received successfully but it wasn’t as expected. A failed node execution means that a node ran into a technical error while executing.

Node Issue Handling

When a node in Bot Studio encounters an issue, for example, when you are sending a message using the Telegram bot’s “Send Message” node and the content of the message is empty, Telegram servers won’t accept that message. In this case, your node has issues. Here is how Bot Studio handles node issues:

  1. Understanding the node’s cause and adding the issue to the bot’s issues list.
  2. Identifying the node which causes the issue and then highlighting it within your bot’s functional system.

Bot Studio strives to inform you about which node has issues in the easiest way for you to track and fix it. This handling system allows you to find all issues within your functional system and fix them as soon as possible.