# More about scripts

Brief video instruction for this section:

{% embed url="<https://www.youtube.com/watch?v=hdMlUPyUma8>" %}

After you have registered with the service, you will have access to a test script - onboarding.

{% hint style="info" %}
**Script** is a sequence of steps that the bot performs in response to events, such as an incoming message in a messenger, joining a group on a social network, or paying for an item in your online store.
{% endhint %}

Go to script. You will see a graph of the bot's dialogue with the subscriber:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FqpPgdxTOyadA1rqLXDfv%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202021-10-13%20%D0%B2%2015.16.24.png?alt=media\&token=017a1a9d-02c2-421e-96e0-f52d787e4176)

Script has *events* and *actions*

An event is an external influence that the bot can respond to. For example, the receipt of a message from a subscriber. An action is a step that the bot performs in response to an event.&#x20;

{% hint style="info" %}
**An event** is an external influence that the bot can respond to. For example, the receipt of a message from a subscriber
{% endhint %}

{% hint style="info" %}
**An action** is a step that the bot performs in response to an event&#x20;
{% endhint %}

Look at the generated script. It has several events (they are highlighted in blue) and arrows leading from them to actions:

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FrC0eg7DUvK8P9deuTTAu%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202021-10-13%20%D0%B2%2016.03.37.png?alt=media\&token=43096c99-29b1-4a9b-abd9-a2ee401a9214)

In the example above, you can see 2 events "message is similar to hello" and "message is equal to acquaintance". This means that the user can get into this scenario if they write the message "hello" or "acquaintance". Moreover, depending on the message, it will fall into different chains.&#x20;

{% hint style="info" %}
**A chain** is an event and the actions that follow it within a script.
{% endhint %}

![](https://1932399487-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuRfd5lEYYH6D50QjzeAX%2Fuploads%2FnDtViL4UJnm4nXsOgcd1%2F%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA%20%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0%202021-10-13%20%D0%B2%2016.11.43.png?alt=media\&token=82fd8e72-b03b-42b9-b3e9-ccbebbe6ff4d)

Smartbot works on a simple principle:&#x20;

If at the moment the user is not in any of the chains, then at the time of the event (for example, a message from the user has arrived), smartbot will look for a suitable scenario and launch the desired chain.
