First, connect [**alfaCRM**](<../../integrations/CRM/alfaCRM.md>).

## Available action

- **Get Branches** - returns the branches with which the bot can work; this is the initial action for the remaining requests.
- **Receive subjects** - returns available directions and subjects.
- **Get lessons** - receives regular or regular classes depending on the format chosen.
- **Get teachers** - returns teachers of the selected branch; the list can be filtered by class type, teacher and subject.
- **Find/Create a client** - searches for a client by phone or email, returns the ID and selected fields, and when set up, creates a new card.
- **Record for a lesson** - writes the client in an existing lesson, always creates a new one or first tries an existing one and, if impossible, creates a new one.

## Find or create a customer

1. Select the search criterion: phone or email.
2. Transmit the value manually or via the `@` variable.
3. Select the card details to be returned to the bot. The customer ID is always returned.
4. If necessary, turn on **In case of unsuccessful search, create a client** and fill in the new card data.

Use the received ID in action **Write to the lesson**.

## Enroll in class.

In the **Method of recording for the lesson**, three modes are available:

- **Write to an existing lesson** - specify the lesson ID;
- **Always create a new lesson** - specify the type of lesson, teacher and subject;
- **Write to an existing one, otherwise create a new** - transmit the ID and parameters of the new lesson in case it is impossible to write to an existing one.

The type of lesson, teacher, and subject can be defined by a bot or limited to reference values and variables.

## Recommended sequence

1. Identify the branch.
2. Get a subject or a lesson.
3. Get the right teachers.
4. Collect student data and confirm the choice.
5. Call **Write down the lesson**.

Do not create a record until the bot knows the branch, lesson, teacher and necessary contact details.
