Calculator functions for courses

Registration for the course

register_customer_on_course(tariff_id, email, email_notification, period, reregistration)

Parameters

! tariff_id

required parameter, the ID of the pricing plan id. You can copy it in the browser line in the pricing plan settings.

! email

required parameter, the client's email address. You can specify a specific value or variable in which the client's email is recorded.

email_notification

optional parameter, sends the student an email message about his registration for the course, if it is enabled.

period

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:

period = '15.08.2023 11:00'

reregistration

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.

purchase_price

optional parameter. Allows you to specify the course cost 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.

Example: register_customer_on_course(123, email, 1, "", True)

circle-info

In order for clients to receive emails, pass 1 to the parameter email_notification.

If you do not send 1, then the client's emails will not be received!

How can I grant access to the course through the Telegram Web App?

To do this, specify the function in the Block Calculator

access_course_from_webapp(text, button_label) During using the function, the student logs in to Telegram and gets access to the course. For further training, the student does not need to enter a username and password, as the authorization has already been completed.

Function Parameters:

text - is the text of the message that the client will receive. The parameter can be specified in a variable by writing it in the Calculator field before accessing the function, or specified in the function itself in quotation marks.

button_label - is the text on the Web App button. You can specify the parameter either in a variable or in the function itself. In the second case, the parameter is written in quotation marks.

circle-exclamation

The screenshot below shows an example of using the function. In the first step, we register the client for the course, then use the access_course_com_webapp function to provide access to the online product.

The result of the function execution:

This button opens a page with the courses/rates that the student has.

If the client is not associated with the student's account, the function returns 'client not attached to customer'.

To create such a connection, you just need to enroll in a course through a bot.

How to grant access to the course via a bot

register_customer_on_course()

To do this, specify the function in the Block Calculator

register_customer_on_course(tariff_id, email, email_notification, period)

Required parameters
Optional parameters

! tariff_id - the ID of the pricing plan ID. You can copy it in the browser line in the pricing plan settings.

email_notification - This parameter sends the student an Email message about his registration for the course, if it is enabled.

! email - the client's email address. You can specify a specific value or variable in which the client's email is recorded.

period - time limit on the validity of the pricing plan. Date formats are supported as follows: %d.%m.%Y %H:%M или %d.%m.%Y Example:

period = '15.08.2023 11:00'

triangle-exclamation

Assign a function to the variable.

After execution, one of the responses will be written in the variable:

customer is already on tariff - if there is a pricing plan or access is manually closed

wrong_tariff_id - invalid id is specified

tariff_added - Pricing plan was added to the student

Example:

How to check the availability of access to the course

has_customer_tariff(tariff_id)

To do this, specify the function in the Block Calculator has_customer_tariff(tariff_id, email)

Required parameters
Optional parameters

! tariff_id - the ID of the pricing plan id. You can copy it in the browser line in the pricing plan settings or in the Pricing plans section.

email - optional parameter. Pass this parameter to check whether the client is enrolled in the course with the specified email address.

After execution, the function returns True or False.

triangle-exclamation

How to register a client on the platform WITHOUT granting access to the course

register_customer(email)

To do this, specify the function in the Block Calculator register_customer(email)

Function Parameters
Description

! email

the client's email address.

You can specify a variable in a function or parameter values. To specify a variable, write its name, without quotation marks and syntax marks, grids and curly braces. To specify a specific value, specify the client's email address in quotation marks.

It is recommended to assign a variable to the function, so you can see the result of the function and work with it. Example in the screenshot below: the variable name is set before the equal sign, followed by the function and parameter in parentheses.

After successful execution of the function, the response will be written in the variable: customer created

How to check course access and time limits?

To do this, specify the function in the Block Calculator has_customer_tariff_with_date(tariff_id, email), to check the availability of access to the course by email (returns a detailed response about the availability of access and time restrictions).

Function Parameters:

Required parameter
Optional parameter

! tariff_id - the ID of the pricing plan id. You can copy it in the browser line in the pricing plan settings or in the Pricing plans section.

email - optional parameter.

The answer will be:

  • the student is enrolled and there is a time limit on access: Has access until 2023-09-28 22:00:00

  • the student is enrolled, there are no restrictions: Has access without time limit

  • the student is not enrolled: No access to this tariff

triangle-exclamation

How to remove access to a student's course via a bot

del_customer_from_course(course_id, email)

To do this, specify the function in the Block Calculator del_customer_from_course(course_id, email)

Parameters
Description

! tariff_id

pricing plan ID

! email

clients's email address

How to check if a student has attended a webinar

customer_was_on_translation()

Access to the course need to be granted in the bot.

There is a function for this register_customer_on_course()arrow-up-right и access_course_from_webapp()arrow-up-right

To check whether a student attended the webinar or not, specify the function in the Block Calculator customer_was_on_translation(translation_guid, email, after_start_time)

Required parameters
Optional parameter

! translation_guid -the broadcast ID. Copy the field value

The name is in the broadcast settings link

after_start_time - the start time of the broadcast in the format: '2023-04-18 13:30:00'.

! email - Student's email address

circle-exclamation

How to find the student's name linked to a bot?

There are cases when students may be linked to the online chat of a student's personal account, as well as those who are linked to a messenger and write to your supervisors via a bot. In order to correctly issue named certificates of completion of the course in the bot and not search for the student's name in the list, there is a function:

get_customer_name() - returns the name of the student associated with the client.

A function with no parameters.

Returns the student's name that the student entered during registering for the course, or the student's name from their personal account.

Last updated