# Selling courses in a chatbot

Setting up online course sales in chatbot is an innovative approach that significantly reduces the time and labor costs of customer service. Using a chatbot, you can automate transactions in real time.

In addition, you can set up data collection in the chatbot for further instant user registration.

In this article, we will look at the process of setting up course sales in the chatbot:

1. Which payment systems are available in the courses;
2. Step-by-step setup of a chatbot to collect data and issue a payment link.
3. Email registration for the course via the bot

## Choosing a payment system

Unlike course payments on the promo page, you can select any payment system you need, which is enabled in your project in the "Payment systems" section:

<div data-with-frame="true"><figure><img src="/files/h7NRiAsOc9ows0Grhr1O" alt=""><figcaption></figcaption></figure></div>

There are a lot of integrations with payment systems in Mavibot.

Each payment system has its own connection features, the description and detailed instructions of which are available in the Mavibot documentation.

To find an article on the selected payment system:

а) or go to the "Integration" section of the documentation -> "[Payment](/integrations/payment.md)", then select the article on connecting the payment service:

б) or, click on "connect" on the service bar in the "Payment systems" section in the project settings:

<div data-with-frame="true"><figure><img src="/files/ZFrMU5VC9weitwN8Ey42" alt=""><figcaption></figcaption></figure></div>

After clicking on the required button, a modal form window opens, where there is already a link to an article with your chosen payment system.

After connecting the payment service, go to the course settings.

Creating an online course involves your personal expenditure of resources on structuring information, its design, presentation, as well as other technical settings.

To receive the necessary and commensurate payment for your knowledge from students, there is a setting of pricin plans and payment acceptance both on the course page and via the chatbot.

{% hint style="info" %}
How to accept payments for online courses on the promo page, read the article of the same name.
{% endhint %}

{% hint style="info" %}
To further configure payment acceptance in the chatbot, you need to set up pricing plans, since the calculator uses the pricing plan ID in the block settings.

To learn how to set up pricing plans, read the article of the same name.
{% endhint %}

## Pricing plan ID&#x20;

To use payment based on the course pricing plans, you need to find the pricing plan ID (or pricing plans) that will be used in the payment function in the block settings in the funnel constructor.

To do this, go to the "Pricing plan" tab by clicking on the corresponding button on the course card in the section with the same name.

<div data-with-frame="true"><figure><img src="/files/QZjt41PiLIkBF5tplXBb" alt="" width="563"><figcaption></figcaption></figure></div>

Then go to the “Payment” tab and select the connected payment provider.

<div data-with-frame="true"><figure><img src="/files/t37KLrKLAz5E2mZJUGYw" alt=""><figcaption></figcaption></figure></div>

Then you will go to the "Plans" section in the course settings.

<div data-with-frame="true"><figure><img src="/files/eLNgCz0IXg2v3bv4fZmU" alt=""><figcaption></figcaption></figure></div>

Plan ID is quite easy to find: it is already visible on the card in the section.

<div data-with-frame="true"><figure><img src="/files/haDC4YvYU2efEF4fnEYa" alt="" width="375"><figcaption></figcaption></figure></div>

Click on the pricing plan ID, then it will be copied to the clipboard and in the future you can use it for payment function.

At this stage, the configuration in the "Courses" section is completed. Go to the configuration of the scheme in the funnel constructor.&#x20;

## Blocks in the funnel constructor

After completing the necessary settings in the online course, go to the funnel constructor, where you will create a scheme for the chatbot.

The scheme will consist of blocks that are responsible for:

1. Data collection: name, email;
2. User's choice of a pricing plan to enroll in the course;
3. Creating a payment link;
4. Register by email for the online course after payment.

### Data collection blocks

The entry-level blocks will be used to collect your client's data: name and email address, which will be needed for further registration of the user for the course.

Step 1. Create the "Start" block. You can add any message in this block.

<div data-with-frame="true"><figure><img src="/files/5Q8nSush0pluQFJuroSJ" alt=""><figcaption></figcaption></figure></div>

You will need this block to start the chatbot scheme, which is responsible for selling and enrolling in an online course.&#x20;

Step 2. Create the following block that tells the user about the available pricing plans:

<div data-with-frame="true"><figure><img src="/files/cXYffGaUbaXZn3BGTPYk" alt=""><figcaption></figcaption></figure></div>

We write a message with the content of the pricing plan and also ask the client about his interest.

Then create two blocks with connections.

<div data-with-frame="true"><figure><img src="/files/eBoNusJz4iiC3nrvJeBh" alt="" width="563"><figcaption></figcaption></figure></div>

Step 3. Create data collection blocks.

This block requests an email from the user, which we will later use the arrow to write to a variable.

<div data-with-frame="true"><figure><img src="/files/bLAuA5X2xUh8MrpBewg9" alt=""><figcaption></figcaption></figure></div>

Then create a block bellow.

<div data-with-frame="true"><figure><img src="/files/xVRofvL7DRjIhM482vO2" alt=""><figcaption></figcaption></figure></div>

Step 4. Create an connection to collect data:

<div data-with-frame="true"><figure><img src="/files/CZicamg6ZO0BUNkR3kVV" alt=""><figcaption></figcaption></figure></div>

<div data-with-frame="true"><figure><img src="/files/Cpuc9yJIsMfaxk0VjGyw" alt=""><figcaption></figcaption></figure></div>

In the connection settings, activate the "User enters data" checkbox and set the variable with the email name.

Also, in the block condition, we put a regular expression for checking email (`^[-\w.]+@([A-z0-9][-A-z0-9]+.)+[A-z]{2,4}$`)

<div data-with-frame="true"><figure><img src="/files/tjeSWKS6blvbhwJvXTw2" alt=""><figcaption></figcaption></figure></div>

This will help the bot to record the email of the accepted sample, rather than a random set of characters or letters.

If necessary, you can create a "Fallback" block from this block, which will respond to the user that the email does not correspond to reality.

<div data-with-frame="true"><figure><img src="/files/HZAMvXjMt4hb6E2ztJGT" alt=""><figcaption></figcaption></figure></div>

You customer cannot switch to the "Fallback" block, so further movement along the funnel will go exactly after the user enters the email address down the funnel.

The regular expression (regEx) used to check email looks like this:

^\[-\w.]+@(\[A-z0-9]\[-A-z0-9]+.)+\[A-z]{2,4}$

{% hint style="info" %}
The entire list of useful regular expressions and their applications can be found in the article "List of useful regular expressions". ссылка [Список полезных регулярных выражений](broken://pages/-M0wjAtzg71YW7LB-2D8)".
{% endhint %}

Step 5. Write a message in the “Chat” block if the client entered their email correctly.

<div data-with-frame="true"><figure><img src="/files/NEuzr7YvXAgp8Ym7TMFD" alt=""><figcaption></figcaption></figure></div>

At this stage, the creation and configuration of data collection units is completed.

### Pricing plan selection blocks

Step 1. Add buttons to the block with the names of the plans.

<div data-with-frame="true"><figure><img src="/files/KaE6RKbhKVR2EZ2iIbOU" alt=""><figcaption></figcaption></figure></div>

Step 2. Next, create two blocks: one that sends the client a payment button for the course, and another that provides access to the free course.

<div data-with-frame="true"><figure><img src="/files/L2DaEQpOsQdZBcnHo7i0" alt=""><figcaption></figcaption></figure></div>

Step 3. Next, in the block with the payment button, add the message: “Please pay to get full access to the course.”

<div data-with-frame="true"><figure><img src="/files/pmvBO0sHCuQ4zErHEQLk" alt=""><figcaption></figcaption></figure></div>

### Student free registration for the course

Now let’s give the client access to the free course. To do this, go to the block connected to the “Free” path.

**Then use the calculator function:** `register_customer_on_course(tariff_id, email, email_notification, period, reregistration, purchase_price)`&#x20;

1. **Enter the ID of the free plan,**&#x20;

<div data-with-frame="true"><figure><img src="/files/oy0oJo5N97snz8qgRKJa" alt="" width="375"><figcaption></figcaption></figure></div>

2. **leave the&#x20;*****email*****&#x20;parameter unchanged,**&#x20;
3. **and set the&#x20;*****email\_notification*****&#x20;parameter to 1.**

You can skip the remaining parameters.

<div data-with-frame="true"><figure><img src="/files/KlvctRkTPg9zm1oLV19v" alt=""><figcaption></figcaption></figure></div>

### Student registration for the course after payment

After successful payment, a system callback message is received in the dialogue with the client:

<div data-with-frame="true"><figure><img src="/files/5H6Ijvr0YyEUcT6nXtDr" alt="" width="290"><figcaption></figcaption></figure></div>

The callback consists of the first ten characters of the secret key, the payment status (success or false), and the payment amount.

{% hint style="info" %}
The callback is not visible in the dialog with the client, it is a system message.&#x20;
{% endhint %}

After the client pays for your course, you can configure the bot's response to the callback and enroll the student in the course.

Step 1. Create a Start block, in the trigger of which we insert a payment callback:

<div data-with-frame="true"><figure><img src="/files/8OnGLoEr5TxDY4e4VXln" alt=""><figcaption></figcaption></figure></div>

This block does not need to be connected to others, it will work itself out after the callback arrives in a dialogue with the client.

Step 2. In the calculator, we prescribe the function of registering a student for a course - register\_customer\_on\_course()

<div data-with-frame="true"><figure><img src="/files/5reokelRbx640l4b4EU4" alt=""><figcaption></figcaption></figure></div>

You need to pass the ID of your pricing plan, at the cost of which the payment was made.

<div data-with-frame="true"><figure><img src="/files/5nGx30sotzEuinn32baQ" alt="The pricing plan ID in the tariff card." width="375"><figcaption><p>The pricing plan ID in the tariff card.</p></figcaption></figure></div>

Next, create a block below, set a timer for automatic message delivery, and add a message confirming that the student has been registered for the course.

<div data-with-frame="true"><figure><img src="/files/2IsNogSp635a7KQ54tAP" alt=""><figcaption></figcaption></figure></div>

#### Function and parameters

**register\_customer\_on\_course(tariff\_id, email, email\_notification, period,** reregistration, purchase\_pric&#x65;**)**

<table><thead><tr><th width="239.15234375">Parsmeters</th><th>Paremeters decription</th></tr></thead><tbody><tr><td><strong>!</strong> <strong>tariff_id</strong></td><td>required parameter, the ID of the pricing plan ID. You can copy it in the browser line in the pricing plan settings.</td></tr><tr><td><strong>! email</strong></td><td>required parameter, the client's email address. You can specify a specific value or variable in which the client's email is recorded.</td></tr><tr><td><strong>email_notification</strong></td><td>optional parameter, sends the student an email message about his registration for the course, if it is enabled.</td></tr><tr><td><strong>period</strong> </td><td><p>optional parameter, time limit for the validity of the pricing plan. Date formats are supported as follows: %d.%m.%Y %H:%M или %d.%m.%Y Example:</p><p><code>period = '15.08.2023 11:00'</code></p></td></tr><tr><td>reregistration</td><td>optional parameter, with values True or False. This parameter is optional and is specified if you need to register students again for the same course and pricing plan.</td></tr><tr><td>purchase_price</td><td>optional parameter. Allows you to specify the cost of the course if the client paid for access to it through a bot. If you do not specify it, the cost of the specified pricing plan will be used. It will be useful if the client pays for access to the course through the bot at a different price than the cost of the specified pricing plan.</td></tr></tbody></table>

{% hint style="info" %}
In order for clients to receive emails, pass 1 in **email\_notification** parameter.

**If you do not send 1, then the client's emails will not be received!**
{% endhint %}

{% hint style="info" %}
All available functions for the course can be found in the article "[Calculator functions for courses](/lms/how-to-sell-courses/selling-courses-in-a-chatbot/calculator-functions-for-courses.md)".
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mavibot.ai/lms/how-to-sell-courses/selling-courses-in-a-chatbot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
