Integration Code Field Guide - Python
Depending on your schema, your integration code will have a variety of commands to call in your SDK. This article covers each command option and what they represent.
Register
Registering an object is how you relate your application data with the schema you had created.
register_user
Mandatory - Registers your users and associated fields
register_interaction
Mandatory - Registers your users’ interactions with your content.
register_object
Optional - Registers any content within your software, such as features, articles, merchandise, etc.
IMPORTANT NOTE: All objects and fields will need to be defined in the schema in order for these calls to work. You can read more about schema definitions in Generate A Schema.
Session
Starting and finishing a user session allows a better understanding of what your user did on your application
start_session()
Requires a user to be registered before. Starts a new session
end_session()
End the most recent open session
IMPORTANT NOTE: Begin AI takes care of mapping the session duration. The
Session
object is available by default on the schema and cannot be modified.Add Field
The
update_*_field
relates to the different field values within your schema (username, genre, author, last sign-in, date of birth, etc). They’re broken down as: for labels:
add_label(*)
Enables the addition of labels to users and objects
Example: add_label(‘User’, 1, ‘real’)
for user:
update_user_text_field
(*)
for object:
update_object_text_field(*)
Related to text-based entries in your schema (for example: names, bios, posts, etc)
Example: update_user_text_field(1, ‘bio’, ‘my great bio’)
for user:
update_user_category_field
(*)
for object:
update_object_category_field(*)
Related to categorical entries in your schema (for example: type, genre etc)
Example: update_user_category_field(1, ‘genre, ‘fiction’)
for user:
update_user_numerical_field(*)
for object:
update_object_numerical_field(*)
Relates to numerical entries in your schema (for example: phone numbers, ISBN codes, etc)
Example: update_object_numerical_field(’Book’, 2, ‘price’, 32)
update_user_boolean_field(*)
for object:
update_object_boolean_field(*)
Relates to boolean entries (for example, active/inactive, true/false, etc)
Example: update_object_boolean_field(’Book’, 2, ‘is_ebook’, True)
update_user_id_field(*)
for object:
update_object_id_field(*)
Relates to other identifier aside from the object/user ID (for example, subscription id, reference_id, etc)
Example: update_object_id_field(’Book’, 2, ‘reference_id’, 101010)
update_user_location_field(*)
Relates to latitude/longitude co-ordinates in your schema.
Example: update_user_location_field(1, ‘present_location’, latitude, longitude)
update_user_date_field(*)
for object:
update_object_date_field(*)
Refers to date fields in your schema.
Example: update_user_date_field(1, ‘birth_date’, date)
HEADS UP: In Python, the date format is required to follow
dd-mm-yyyy
. For example, July 10th, 1985 will need to be expressed as 10-07-1985
. Each call will follow the source key, source id, and value in parenthesis. For example, if under the “book” object a “book title” field is present, a call will be available for:
begin_Worker.update_object_text_field('Book', 2, 'book_title', 'Thinking fast & slow.')
Learn
learn_from_data
call will generate an anonymized signature using the registered content and submit it to Begin AI’s servers for learning.