API in Calculator

Simplified API calls from the calculator

API Salebot

How To Send Callback

To send a colbeck, use the function:

callback(client_id, callback_message)

client_id - client ID

callback_message - message in callback

The client with the specified id will receive a notification, which can be caught:

You can use your callback function for Telegram:

tg_callback(platform_id, callback_message)

How to send a message to the client

To send text or block from the funnel to the client, the following function is used:

message(client_id, text, message_id)

client_id - client ID

text - message in kolbek (None if used message_id )

message_id - block identifier (optional)

To send a message not via ID, but by phone number via whatsapp there is a function:

whatsapp_message(phone, text, message_id)

API Telegram

Details about connecting and using Telegram HERE

Works only on "Premium" tariff

How to attach voice messages, photos, videos, animations and stickers with internal Telegram files, read here

How to send a document

tg_send_document(platform_id, document, caption, reply_markup, parse_mode,reply_to_message_id, protect_content)

where platform_id is the client id in the messenger, document - a link to the document to be sent, caption - a description (optional parameter), reply_markup - button settings (optional parameter), parse_mode - text selection in the description in bold or italic (optional parameter)reply_to_message_id - the id of the quoted message (optional), protect_content - for copy protection (optional parameter if you want to enable, pass as parameter 1)

How to Send a Voice Message

tg_send_voice(platform_id, voice, caption, reply_markup, parse_mode, reply_to_message_id, protect_content)

where platform_id - client id in messenger, voice - link to voice message in format . OGG, caption - description of up to 1024 characters (optional parameter), reply_markup - button settings (optional parameter), parse_mode - description text in bold or italic (optional parameter), reply_to_message_id - quotation message id (optional parameter), protect_content - for copy protection (optional parameter, if you want to enable, pass as parameter 1)

How to send animations

tg_send_animation(platform_id, animation, caption, reply_markup, parse_mode, reply_to_message_id, protect_content)

where platform_id - client id in messenger, animation - animation link, caption - description up to 1024 characters (optional parameter), reply_markup - button settings (optional parameter), parse_mode - text selection in description in bold or italic (optional parameter)reply_to_message_id - the id of the quoted message (optional), protect_content - for copy protection (optional parameter if you want to enable, pass as parameter 1)

How to send video

tg_send_video(platform_id, video, caption, reply_markup, parse_mode, reply_to_message_id, protect_content)

where platform_id - client id in messenger, video - link to video, caption - description up to 1024 characters (optional parameter), reply_markup - button settings (optional option), parse_mode - bold or italic text selection (optional), reply_to_message_id - the id of the quoted message (optional), protect_content - to protect against copying (optional parameter, if you want to enable, pass as parameter 1)

How to send a geopoint

tg_send_venue(platform_id, latitude, longitude, title, address, protect_content)

where data are entered: platform_id - the client id in messenger, latitude - latitude, longitude - longitude, title - name, address - address, protect_content - for copy protection (optional parameter, if you want to include, pass as parameter 1).

How to send contact

tg_send_contact(platform_id, phone, first_name, last_name, protect_content)

where phone - phone number in international format. For example, for RF it is +7XXXXXXXX, first_name and last_name are entered manually, protect_content - for copy protection (optional parameter, if you want to enable, pass as parameter 1).

How to Send Sticker

tg_send_sticker(platform_id, sticker_id, protect_content)

where platform_id is the client’s id in the messenger, sticker_id is the id of the sticker. It can be obtained by sending the appropriate sticker to the bot https:///t. me/RawDataBot. In response the bot sends the data, we need the last parameter file_id, protect_content - for copy protection (optional parameter, if you want to enable, pass as parameter 1).

It can be obtained by sending the required sticker to https:/t. me/RawDataBot. In response the bot sends the data, we need the last parameter file_id.

How to send a round video

tg_send_video_note(platform_id, video_note, reply_markup, protect_content)

where platform_id - client id in messenger, video_note - video id. You can get it by sending the desired video bot https://t. me/RawDataBot. In response the bot sends the data, we need the last parameter file_id, reply_markup - button settings (optional parameter), protect_content - for copy protection (optional parameter, if you want to enable, pass as parameter 1).

How to send a picture

tg_send_photo(platform_id, photo, caption, reply_markup, parse_mode, protect_content)

where

platform_id - client id in messenger,

photo - a link to a picture or file_id obtained from RawDataBot bot,

caption - description up to 1024 characters (optional parameter),

reply_markup - button settings (optional option),

parse_mode - bold or italic text selection (optional),

protect_content - to protect against copying (optional parameter, if you want to enable, pass as parameter 1)

How to send some pictures:

tg_send_some_photo(platform_id, image_list, disable_notification=0)

platform_id - customer id in messenger

image_list - an array of pictures (more info below)

disable_notification - optional parameter, default 0 - disable notification on receipt, pass 1

Example image_list:

'[["Picture link 1", "caption", "parse_mode"], ["Picture link 2"], ["Picture link 3", "caption"]'

One image data example: ["Picture link 1", "caption", "parse_mode"]

The order of the parameters is important. One parameter is enough - links to the picture, the rest are optional.

Parameters Description:

1 - link to the picture

caption - signature (not required) parse_mode - description markup (optional)

How to send a message:

To send a message you need to use one of these functions:

tg_send_message(platform_id, text, client_message_id=None, reply_markup=None, parse_mode=None, disable_web_page_preview=0, protect_content=False)

OR

tg_send_message_1(token, platform_id, text, client_message_id=None, reply_markup=None, parse_mode=None, disable_web_page_preview=0, protect_content=False) - sending a message to a telegram indicating the bot

The function tg_send_message_1 differs from tg_send_message by the first parameter

token - token Telegram bot from BotFather

platform_id - id to Telegram, where to send a message

client_message_id - the message identifier to be quoted (optional)

reply_markup - button settings (optional)

parse_mode - bold or italic text selection (optional)

protect_content - for copy protection.

If you want to enable this option, set text in bold or italics as parameter 1 (optional)

Where to get platform_id to send notifications:

  • you must have telebots connected to the project In this bot

  • you need to send any message from that telegram-account, where should be sent messages about the applications

  • go to Clients in Salebot

  • in the list of dialogs select a dialog with the telegram-account to which you will send the requests

  • copy the ID value in the messenger

Example of sending cursive text:

tg_send_message(47615196, "italic", None, None, None,"html")

Example of sending bold text:

tg_send_message(platform_id, 'test', None, None, 'markdown')

Example of sending a message with buttons:

opts = {"keyboard":[[{"text": "Left"}, {"text": "Right"}]]} r = tg_send_message(platform_id, "Go left - the horse is lost, go right - you are lost, go straight - happiness is found", None, opts, None, 0)

It is important to remember that reply_markup takes the json format, and the calculator recognizes only the linear writing of the text (without Enter), so make sure there are no string hyphens

To learn more about how to work with buttons when sending messages, read the Telegram documentation https://tlgrm.ru/docs/bots/api#keyboardbutton

How to send a message:

tg_forward_message(platform_id, from_chat_id, message_id, protect_content)

where platform_id - where to forward the message, from_chat_id - value #{platform_id}, where to forward the message, message_id -id of the message to be forwarded, protect_content - to protect against copying (optional parameter, if you want to enable, pass as parameter 1).

tg_create_chat_invite_link(platform_id, member_limit=None, hours=None, request=None)

where

platform_id - client id in messenger,

member_limit - limit on number of participants,

hours- the number of hours that the link will be valid,

request - will be formed at the transition request to join or not.

If the parameter member_limit is passed, the request parameter is automatically replaced by False. If you want to accept membership requests, the member_limit parameter is left blank.

tg_revoke_chat_invite_link(platform_id, invite_link)

where

platform_id - client id in messenger,

invite_link - link to be deleted

How to Block a Client

tg_ban_chat_member(platform_id, user_id, hours=99999, revoke_messages=True)

where

platform_id - client id in messenger,

user_id - user id to lock,

hours - how many hours lock,

revoke_messages - optional parameter, means, delete all user messages or not

How to Unblock a Client

tg_unban_chat_member(platform_id, user_id, only_if_banned=True) where

platform_id - client id in messenger,

user_id - user id to lock

How to check the subscription in Telegram

result = tg_get_chat_member(platform_id, user_id) - get the user from the group channel (use to check subscription) see example below

where

platform_id - client id in messenger (can be passed via variable #{platform_id}),

user_id - id of the user we are checking

Result: If there is a group in the channel

{"ok":true,"result":{"user":{"id":613182600,"is_bot":false,"first_name":"NAME","last_name":"LAST_NAME},"status":"untistatus","l_date":0}}

Result: If not in channel group

{"ok":true,"result":{"user":{"id":123456,"is_bot":false,"first_name":"username":"username","language_code":"""},"status":"left"}}

There is a feature of Telegram itself, if the client did not directly contact the bot, then if it is not in the channel group, the method returns 400 response {"ok":false,"error_code":400,"description":"Bad Request: user not found"}

so we format it as a generic view, for convenience, and send the following answer: {"ok":true,"result":{"user":{"id":123456,"status":"left"}} where 123456 is the user.

Examples of how to get values:

result = tg_get_chat_member('-10015109988', '613182600') res = get(result, 'result') member_status = get(res, 'status')

member_status - left - does not belong to the channel group member_status records the user status (member, kicked, creator, administrator, etc) or None if the user is not found or an error occurs.

How to Edit Messages

You can only edit in-line keyboard.

  • Editing the text in the message: tg_edit_message_text(platform_id, message_id, text, reply_markup, parse_mode, disable_web_page_preview)

where: the parse_mode, reply_markup, disable_web_page_preview optional parameters to enable disable_web_page_preview in this parameter must pass 1, and to turn off - 0.

  • Edit description: tg_edit_message_caption(platform_id, message_id, caption, reply_markup, parse_mode)

where: the reply_markup parameter is optional. The parse_mode parameter - text in description in bold or italic (optional parameter)

  • Media message editing: tg_edit_message_media(platform_id, message_id, media, reply_markup)

where: reply_markup is optional

How to delete a message

tg_delete_message(platform_id, message_id) where platform_id - client id in messenger, message_id - message id

How to Install Parse_mode

parse_mode selects all text/part of it in italic or bold font. It may have html or markdown values.

If you choose html:

for bold text use "<b>caption</b>"

for the italic text use "<i>caption</i>"

For Markdown:

for bold font use "*caption*"

for italic "_caption_"

Example:

How to Determine the Number of Members in a Channel/Chat

For this function to work, your bot must be a channel/chat administrator.

To determine the number of participants in the calculator, use the function tg_get_chat_member_count(platform_id)

where platform_id is a group identifier. Assign a variable to this function as shown in the example:

count = tg_get_chat_member_count(-100160754137668)

This variable will get a server response of this type: {"ok":true,"result":6}

Where result is the number of users in the group together with admins and bots.

How to show the user bot actions (typing/choosing sticker, etc.)

For this function to work, your bot must be a channel/chat administrator.

To show the actions of the bot at the moment (to make some announcement of the following message), use the function:

tg_send_chat_action(platform_id, bot_action),

where platform_id is the group identifier, and bot_action is the bot action from the list. In the example above, while the request is being processed, the "bot prints" notification will be displayed, as the action is written with an error.

tg_send_chat_action(-100160754137668, 'choose_sticker') - correct spelling

Choose one of the actions depending on what the user will get:

typing for text messages

upload_photo for photos

record_video or upload_video for video

record_voice or upload_voice for voice notes

upload_document for shared files

choose_sticker for stickers

find_location for location data

record_video_note or upload_video_note for video notes.

This notification will be displayed until any response from the bot arrives, but no more than 5 seconds.

General restrictions for regular chat users or for individual users

For the functions described, your bot must be a channel/chat administrator.

To limit the ability of all users (except admins) in the calculator you can use the function

tg_chat_permission(platform_id, permission)

platform_id is the chat identifier, and permission is the value array for the restriction list listed below. In an array, the value 1 resolves the action and the value 0 - prohibits. The sequence number corresponds to the position in the array

  1. can_send_messages - permission to send text messages, contacts, locations and venues

  2. can_send_media_messages - the permission to send audio, documents, photos, videos, video notes and voice notes is assumed to have the permission can_send_messages

  3. can_send_polls - permission to send surveys is assumed to have can_send_messages permission

  4. can_send_other_messages - permission to send animations, games, stickers and use built-in bots, assumes the presence of permission can_send_media_messages

  5. can_add_web_page_previews - permission to add a preview of a Web page to its messages is assumed to have permission can_send_media_messages

  6. can_change_info - permission to change chat name, photo and other settings. Ignored in public super groups

  7. can_invite_users - permission to invite users

  8. can_pin_messages - permission to commit messages. Ignored in public super groups In this example, users are prohibited from doing any of the following:

permission = [0, 0, 0, 0, 0, 0, 0, 0]

tg_chat_permission(-10016071312347668, permission)

In this example, everything is allowed:

permission = [1, 1, 1, 1, 1, 1, 1, 1]

tg_chat_permission(-10016071312347668, permission)

It is better to place the array with permissions in a separate variable

Also, in order to restrict any user, it is possible to prescribe him personal restrictions through the function

tg_restrict_chat_member(platform_id, user_id, minutes, permission).

platform_id - chat ID

user_id - user identifier

minutes - the number of minutes during which the limit will be valid (if you do not specify explicitly, the default value will be 3600, which corresponds to 60 hours, and if you specify 0, the restrictions will be valid indefinitely)

permission - an array of values for a constraint list similar to that of the function tg_chat_permission

An example of a feature where a user is banned for 3 minutes: permission = [0, 0, 0, 0, 0, 0, 0, 0] tg_restrict_chat_member(-1001607137668, 473737685, 3, permission)

When you enter the chat room, you will be notified that you are unable to write to the chat, and if you have set a time limit, you will see the expiry date of this limit.

Use with caution. All existing links to join your group will become inactive.

tg_export_chat_link(platform_id)

where platform_id is the id of the group in Telegram, in which you want to render all existing links inactive. If successful, the link will be returned, which will be the only way to get into the group until additional links are created again by other means.

How to pin a message

tg_pin_chat_message(platform_id, message_id, disable_notification)

where

platform_id - id of the group in Telegram in which you want to secure the message,

message_id - id of the message to be secured,

disable_notification - Specifies whether to send a notification to all chat members about the new assigned message (notifications are always disabled in channels and private chats). If you do not want to send notifications.

If you do not want to send notifications in disable_notification parameter put 1, if you want - 0

How to unpin a message

tg_unpin_chat_message(platform_id, message_id)

where platform_id is the id of the group in Telegram in which the message needs to be undocked, and message_id (optional) is the id of the message to be undocked. If the message_id is not specified, the most recent fixed message (by sending date) will be detached.

How to Unpin All Pinned Messages

tg_unpin_all(platform_id)

where platform_id is the id of the group in Telegram, in which you need to unpin all messages.

How to Set an Avatar on a Group/Chat

tg_set_chat_photo(platform_id, photo), where platform_id is the chat identifier in which you want to set the avatar, photo - link to photos.

The link photo should not exceed 10 MB

tg_set_chat_photo(-1001607137668123, 'https://static10.tgstat.ru/channels/_0/f8/f8198fa2a90c053842ef5f284f03e9d.jpg')

How to Delete a Group/Chat Avatar

tg_delete_chat_photo(platform_id), where platform_id is the chat identifier in which you want to remove the avatar.

tg_delete_chat_photo(-1001607137668123)

How to install/view/remove bot commands

To set commands

tg_set_command(commands, language, scope, platform_id, user_id), where

commands - commands for a bot as a list of lists, each nested list consists of 2 elements, of which 1 - the command name and 2 - its description (there is a limit of 100 commands),

language - a two-letter language code ISO 639-1, for example 'en' or 'en' (optional parameter, if not specified, the commands will be applied to all users from a given area for which no commands are allocated),

scope - parameter describing the range of users for which commands are created (optional parameter, if you do not use default will be set to 'default'),

platform_id - chat identifier (optional parameter, applied only with defined scope parameter values),

user_id is a user identifier (optional, applied only with defined scope parameter values).

command = [["count", "return count of user"],["unpin", "unpin all message"]] tg_set_command(command, '', 'all_chat_administrators')

In this example, the commands are set to a single variable. You can also add these commands directly to the function:

tg_set_command('[["count", "return count of user"],["unpin", "unpin all message"]]', '', 'all_chat_administrators')

To further invoke commands, type the '/' symbol in the message input box. If this is correct, you will see the prompt as a command list. In bold, the commands are shown to the right.

To use commands, configure the response to messages containing commands.

For commands in correspondence with a bot to respond to messages of the form: '/command_name' - in this example command_name - command.

For commands in groups and chat rooms, you need to respond to messages like: '/command_name@bot_username' - in this example command_name - command, and @bot_username - username bot.

Scope option options:

'default' - the default parameter, implies that commands will work in personal messages with the bot.

'all_private_chats' - all closed chats, commands are available to everyone in private chats, in which a bot is added.

'all_group_chats' - all group and super group chats, commands are available to everyone in the specified types of chats, in which a bot is added.

'all_chat_administrators' - commands for administrators of all group and super group chats, in which a bot is added.

'chat' - commands for a certain chat (if you choose this option, you must specify platform_id).

'chat_administrators' - commands for the administrators of a certain chat (if you choose this option, you must specify platform_id).

'chat_member' - commands for a particular member of a particular chat (if you select this option, you must specify platform_id and user_id, the specified user must be in the specified chat).

If you do not want to use the language parameter but use the scope parameter, be sure to specify an empty parameter after the commands, as in the example: tg_set_command(command, ', scope)

To view commands

tg_get_command(language, scope, platform_id, user_id), where

language - a two-letter language code ISO 639-1, for example 'en' or 'en' (optional parameter, if not specified, will be shown the commands applied to all users in the specified area, for which language is not allocated commands),

scope - parameter describing the range of users to which commands should be shown (optional parameter, if you do not use default will be 'default'),

platform_id - chat identifier (optional parameter, applied only with defined scope parameter values),

user_id is a user identifier (optional, applied only with defined scope parameter values).

command = tg_get_command(', 'all_chat_administrators')

Assign the variable as a value to this function, and within the variable there will be a server response with commands for the circle of users specified in the scope parameter.

{"ok":true,"result":[{"command":"count","description":"return count of user"},{"command":"unpin","description":"unpin all message"}}}

If you call a function without parameters, the scope will default to 'default'.

command = tg_get_command()

If you do not want to use the language parameter but use the scope parameter, be sure to specify an empty parameter at the beginning, as in the example: tg_get_command(', scope)

To delete commands

tg_delete_command(language, scope, platform_id, user_id), where

language - a two-letter language code ISO 639-1, for example 'en' or 'en' (optional parameter, if not specified, will be removed commands that apply to all users in a given area for which there are no dedicated commands),

scope - a parameter that describes the range of users for which the commands are removed (optional parameter, if you do not use default will be 'default'),

platform_id - chat identifier (optional parameter, applied only with defined scope parameter values),

user_id - a user identifier (optional, applied only with defined scope parameter values).

tg_delete_command('', 'all_chat_administrators')

If you do not want to use the language parameter but use the scope parameter, be sure to specify an empty parameter at the beginning, as in the example: tg_delete_command(', scope)

The tg_delete_command() removes commands without specifying the language parameter from the default scope parameter.

How to Send Files in Telegram

In send_document, send_voice, send_animation, send_video, send_photo methods you can not insert links to external resources, but use Telegram files.

For example, we need to send a voice message. To do this, we will use the https://t. me/mp3toolsbot bot. Send him the file you want to convert to OGG format. Then click Voice Converter and then Save.

At the end we get:

Next we send this message to our bot and from there we send it to https://t. me/RawDataBot. We get an answer where we need to copy the last file_id value

We put it in here:

and you get this

If you send the file directly from the mp3 Tools bot to Telegram bot Raw, there will be an error:

So first you need to send to your bot, and from it - Telegram bot Raw, If you need to send a video, photo, document, send the desired file to your bot and from there forward it to Telegram bot Raw. Then copy file_id, etc., as described above.

API AmoCRM

Details about AmoCRM Connection and Usage HERE

If you do not have the right method, contact support.

How to get a token

To receive a token, use the following method:

amo_token = amo_get_token()

How to add a new deal

To add a new transaction, you can use amo_add_lead(lead_data, contact ID) method - optional parameter, automatically taken from variable amo_client_id.

lead_data - a dictionary with a dataset for the new lead. The lead_data parameter has the form of a dictionary in single quotation marks, keys and values in double. Maximum set of parameters:

amo_add_lead('{"name": "New LID", "budget": budget, "responsible_id": ID of the responsible}')

Responsible Identifier - First Employee Created by Default

Minimum parameter set: amo_add_lead('{"name": "New LEAD"}')

How to rename the transaction

To rename a client transaction, it is enough to call the function amo_set_lead_name(New name, transaction identifier) transaction identifier - optional parameter, automatically taken from variable amo_lead_id

Example: amo_set_lead_name("New Name")

How to move a deal in the pipeline

amo_change_state(status_id, lead_id=None, pipeline_id=None)

Options:

status_id - id of the pipeline stage on which to transfer the bot,

lead_id - id of the lead to be moved (optional parameter, default is taken from variable amo_lead_id)

pipeline_id - pipeline ID if deal is in other pipeline amo (optional parameter)

If the deal number is raised from the standard amo_lead_id variable, then it can be omitted: amo_change_state(status_id, "", pipeline_id)

The id status must be taken from the sources of the AmoCRM page:

How to get information about the deal

amo_get_lead_info(lead_id=None)

where lead_id is the deal id (optional, default is amo_lead_id).

Get the value of the custom deal field

amo_get_lead_custom_field(var_id, lead_id=None)

where lead_id is the transaction id (optional, default is amo_lead_id).

var_id - the custom field number or its name from which to get the value

You can find the custom field number by opening a link in the browser: your domain.amocrm.ru/api/v4/leads/custom_fields

How to Send Custom Fields to a Deal

Transfer of one value to a custom field:

amo_add_lead_custom_fields("field identifier", "Value")

You can also manually transmit the transaction identifier with the third parameter, otherwise it is automatically pulled from the variable: amo_lead_id

amo_add_lead_custom_fields("field identifier", "value", "transaction identifier")

Transfer multiple values simultaneously:

amo_add_lead_custom_fields('{"field ID": "Value", "field ID": "Value 2", "field ID 3": "Value"}')

Example: amo_add_lead_custom_fields('{"582601": "222333333", "588091": "red"}')

You can also manually transmit the transaction identifier with the third parameter, otherwise it is automatically pulled from the variable: amo_lead_id. With the second one you need to pass two single quotes!

amo_add_lead_custom_fields('{"field identifier": "Value", "field identifier": "Value 2", "field identifier": "Value 3"}', ', "deal identifier")

How to get customer information

amo_get_contact_info(contact_id=None)

where amo_contact_id is the id of the transaction, the information about which must be obtained (optional parameter, by default is taken from the variable amo_contact_id).

How to Get Custom Client Field Value

amo_get_contact_custom_field(var_id, contact_id=None)

where amo_contact_id is the id of the contact that you want to get information about (optional parameter, default is taken from the variable amo_contact_id). var_id - the custom field number or its name from which to get the value

You can find the custom field number by opening a link in the browser: Your domain.amocrm.ru/api/v4/contacts/custom_fields

How to Send Custom Field to Contact

Transfer of one value to a custom field:

amo_add_contact_custom_fields("field identifier", "Value")

You can also manually transmit the transaction identifier with the third parameter, otherwise it is automatically pulled from the client variable: amo_client_id amo_add_contact_custom_fields("field identifier", "value", "transaction identifier")

Transfer multiple values simultaneously:

amo_add_contact_custom_fields('{"field identifier": "Value", "field identifier": "Value 2", "field identifier 3": "Value"}')

Example: amo_add_contact_custom_fields('{"582601": "222333333", "588091": "red"}') You can also manually transmit the contact ID with the third parameter, otherwise it is automatically pulled from the client variable: amo_client_id. With the second one you need to pass two single quotes!

amo_add_contact_custom_fields('{"field identifier": "Value", "field identifier": "Value 2", "field identifier": "Value 3"}', ', "transaction identifier")

How to Create a Task

amo_create_task(title, assigned_id, minutes_deadline, task_type_id, lead_id=None)

where

lead_id is the deal id for which you want to set the task (optional parameter, default is taken from the variable amo_lead_id).

deadline - time in minutes before completion of the task,

assigned_user_id - id of the responsible

task_type_id - task type id,

title - task text

To get the task type id you need to open a link in the browser: Domain.amocrm.ru/api/v4/tasks

How to set Tags

amo_set_tags(tags, lead_id=None)

where lead_id is the id of the transaction for which the tags are set (optional parameter, default is taken from the variable amo_lead_id). tags - list of tags listed by comma.

How to set budget

amo_set_budget(budget, lead_id=None)

where lead_id is the deal id for which the budget is set (optional parameter, default is taken from the variable amo_lead_id). budget - amount of a deal

How to Insert Notes

amo_add_notes(text, lead_id=None)

where lead_id is the deal id for which the budget is set (optional parameter, default is taken from the variable amo_lead_id). text - note text

How to Change Contact Name

amo_set_contact_name('First Name', 'Last Name')

The first parameter is required!

Example: amo_set_contact_name('John', 'Parker') You can also manually transmit the contact ID with the third parameter, otherwise it is automatically pulled from the client variable: amo_client_id. In this case, if the second parameter (surname) is not passed, then two single quotation marks should be given instead!

Example: amo_set_contact_name('John, ', '1234567')

How to set contact phone number and e-mail

To set the client’s phone number and e-mail in AmoCRM, you need to set the variables in the «Calculator» field:

client.phone = Phone

client.email = Email

Data from these variables are transmitted in yellow and red blocks in CRM

How to Set Responsible Person for Deal

amo_set_lead_responsible_user( responsible_user_id, lead_id=None) where responsible_user_id is the assigned user identifier

Example: amo_set_lead_responsible_user(5912572)

How to Find a Field ID

The field ID can be found in the page code by right-clicking on the field name:

API Bitrix 24

Details about connecting and using Bitrix 24 HERE

How to add a comment

Deal

bitrix_add_deal_comment(text, bitrix_deal_id)

where text - the text of the comment bitrix_deal_id is an optional parameter, the deal identifier, if not passed automatically will be taken from the variable bitrix_deal_id

Contact

bitrix_add_contact_comment(text, bitrix_contact_id) text - bitrix_contact_id comment text - optional parameter, contact identifier, if not transmitted automatically will be taken from the bitrix_contact_id variable

Lead

bitrix_add_lead_comment(text, bitrix_lead_id) text - bitrix_lead_id comment text - optional parameter, lead identifier, if not passed automatically will be taken from the variable bitrix_lead_id

How to change the responsible

Lead

bitrix_deal_responsible(assigned_by_id, bitrix_lead_id) assigned_by_id - user id in bitrix bitrix_deal_id - optional parameter, transaction identifier if not transferred automatically will be taken from bitrix_id variable

Contact

bitrix_contact_responsible(assigned_by_id, bitrix_lead_id) assigned_by_id - user identifier in bitrix_contact_id - optional parameter, contact identifier, if not transmitted automatically will be taken from the variable bitrix_ct_id

Lead

bitrix_lead_responsible(assigned_by_id, bitrix_lead_id) assigned_by_id - user identifier in bitrix_lead_idbitrix - optional parameter, lead identifier, if not transmitted automatically will be taken from bitrix_lead_variable id

How to Change Fields

Deal

bitrix_deal_fields(fields, bitrix_deal_id) fields - dictionary with field names and values, description below (reference to field names below) bitrix_deal_id - optional parameter, deal identifier, if not transferred automatically will be taken from the variable bitrix_deal_id

Contact

bitrix_contact_fields(fields, bitrix_deal_id) fields - dictionary with field names and values, description below (reference to field names below) bitrix_contact_id - optional parameter, contact identifier, if not transmitted automatically will be taken from the variable bitrix_ct_id

Lead

bitrix_lead_fields(fields, bitrix_deal_id) fields - dictionary with field names and values, description below (reference to field names below) bitrix_lead_id - optional parameter, lead identifier, if not passed automatically will be taken from variable bitrix_d_id

The fields parameter has the form of a dictionary in single quotation marks, keys and values in double: '{"Field name": "value", "Field name": "value 2"}'

For example, change the fields in the transaction:

bitrix_lead_fields('{"ADDITIONAL_INFO": "More information", "UTM_CONTENT": "Campaign Content"}')

Deal

bitrix_deal_search(search_filter, select_fields, order)

Contact

bitrix_contact_search(search_filter, select_fields, order)

Lead

bitrix_lead_search(search_filter, select_fields, order)

Product

bitrix_product_search(search_filter, select_fields, order)

In all these functions:

search_filter - a dictionary with field names and filter values (links to field names below)

Example: '{">OPPORTUNITY": 0, "STAGE_ID": "NEW"}' - OPPORTUNITY greater than 0 and STAGE_ID equals NEW If you want to negate, add an exclamation point at the beginning. Example: "! STAGE_ID": "NEW" - NOT NEW

select_fields - an array of field names to get as a result (optional parameter) Example: '["ID", "TITLE"]'

order - (optional parameter) sorting options.

As a result, the function returns a dictionary with two parameters: {'result': [], 'total': 0} result - an array of total values found - how many are found

Example: result = bitrix_deal_search('{"STAGE_ID": "NEW}', '["ID", "TITLE", "UF_CRM_1637142365873"]') condition for filter is transaction on NEW stage and return for transactions identifier, header and user field found (Read https://docs.salebot.pro/integracii/crm/integraciya-sbitriks-24#kak-uznat-id-zovatelskogo-polya )

As a result, if such trades are found the following answer: {'result': [{'ID': '5', 'UF_CRM_1637142365873': 'field value'}, {'ID': '7', 'UF_CRM_1637142365873': None}, 'total': 2}

How to Find Entity Field Names

Links to the available standard fields can be found at: https://docs.salebot.pro/integracii/crm/integraciya-s-bitriks-24#zapolnenie-polei-sdelok-i-lidov

API in Google-Tables

Details about connecting and using google tables HERE Each function accepts the first sheet_id parameter of the table identifier. You can get it from the link to your Google table (what is highlighted in bold in the link below). https://docs.google.com/spreadsheets/d/1aUbbUaw2SRnJFAavv06Noa1EzumhyShKDm7ie6lYlc4/edit#gid=0

For convenience, it is better to write the table identifier into a variable and pass it to functions

All functions described below return a dictionary with the result. It must include status, which, depending on the result, is either true in success or false in error.

If the status is true, there may be other parameters that can be obtained using the get() function

If the status is false, the err parameter with the error description is present.

If you do not plan to work with the first sheet of the table, you can pass an additional parameter worksheet_name_or_id_or_index. Each function accepts this parameter, which corresponds to either the name of the sheet or its identifier.

Dictionary - Some functions accept the dictionary parameter with a set of specific data. There are a number of rules to follow:

  • the whole dictionary is in single quotes '{}'

  • keys and values (text or variable) in the dictionary are enclosed in double quotation marks '{"key": "value", "key2": "#{email}"}'

How to add a new sheet to the Google table

It is carried out with the help of the function:

sheet_create_worksheet(sheet_id, list_name, cols=None, rows=None)

The function returns a dictionary with a new sheet identifier and True status ({"status":true,"list_id":1063146761}) or an error description if False status ({"status":false,"err":"Error or description"})

Example:

result = sheet_create_worksheet('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzTl', "New List") status = get(result, 'status')

How to Write in Lines to Specific Columns

You can collect a lot of data from the user and write them into the first free row in the table.

The cap must be filled in (at least one cell in the first row)

It is carried out with the help of the function:

sheet_mapping_cells(sheet_id, cell_data, worksheet_name_or_id_or_index=None)

sheet_id is your Google Table ID.

cell_data - dictionary with parameters. '{"A": "value", "D": "#{email}}}- where the key is the letter of the column

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number or sheet identifier

If there is no problem with the query execution, the dictionary {"status":true,"number_row":14} comes back, you can save the number of the number_row string and use it for further work.

Example:

result = sheet_mapping_cells('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzT', '{"a":"aaaaa", "B": "#{email}"}')

status = get(result, 'status')

number_row = get(result, 'number_row')

How to Write Data to Specific Cells

It is carried out with the help of the function:

sheet_write_cells(sheet_id, cell_data, worksheet_name_or_id_or_index=None)

sheet_id is your Google Table ID.

cell_data - a dictionary with parameters. '{"A1": "value", "D4": "#{email}}}, where the key is a column letter and a row number

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number (starting from 1) or sheet identifier

Example: cell_data:

'{"a1":"#{variable}", "b3": "#{variable}", "c1": "12545", "d20":"just text"}'

Recording is done in specific cells that you specify (in our example a1, b3, c1, d20)

If there is no problem in execution of query, the answer comes dictionary {"status":true} or error description {"status":false,"err":"Error or description"}

Example sheet_write_cells: With sheet identifier 123456789:

result = sheet_write_cells('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzTl', '{"a1":"a3", "b3": "#{email}"}', '123456789')

result = sheet_write_cells('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzTl', '{"a1":"a3", "b3": "#{email}"}')

status = get(result, 'status')

How to Remove an Entry from Specific Cells

It is carried out with the help of the function:

sheet_remove_cells(sheet_id, cell_list, worksheet_name_or_id_or_index=None)

sheet_id is your Google Table ID.

cell_list - array of cells. Example: '["A1", "D4"]' - where column letter and row number

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number (starting from 1) or sheet identifier If there is no problem in executing the query, the answer comes dictionary {"status":true} or error description {"status":false,"err":"Error or description"}

Example:

With sheet identifier 123456789:

result = sheet_remove_cells('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzT', '["a1", "b3", "c2"]', '123456789')

result = sheet_remove_cells('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzT', '["a1", "b3", "c2"]')

status = get(result, 'status')

Removes values from specific cells you specify (in our example a1, b3, c2) Column numbering starts with one.

How to write to the first empty cell in a row

You can write the data to the specified row, the entry will take place in an empty cell to the right of the last filled cell. It is carried out with the help of the function:

sheet_append_cell_in_row(sheet_id, row, value, worksheet_name_or_index=None)

sheet_id is your Google Table ID.

row - the number of the row in which you write

value is the value that will be written into the cell

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number (starting from 1) or sheet identifier

If there is no problem with the query execution, the answer comes {"status":true, "number_col":10,"col_name":"J3"}.

You can save these numbers and use them for further work. In case of error will come dictionary with false status and error description {"status":false,"err":"Error value"}

Example: Write to the empty cell of the first row.

result = sheet_append_cell_in_row('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzT', 1, "Value")

How to Read Table Data

It is carried out with the help of the function:

sheet_read_cells(sheet_id, cell_data, worksheet_name_or_id_or_index=None)

sheet_id is your Google Table ID.

cell_data - dictionary with ranges.

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number (starting from 1) or sheet identifier Cell_data example: '{"a1":"a1", "a3": "b4", "c1": "c3"}'

In the example "a1":"a1" returns the value of one cell and "c1":"c3" returns 3 values from column C.

If there is no problem with the query execution, the response comes a dictionary containing the status and all cells with the values {"status":true,"A1":","A3":"value","B3":"value","A4":"value", "B4":"""DD1:", "C2." {"status":false,"err":"Error or description"}

Example: With sheet identifier 123456789:

result = sheet_read_cells('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzTl', '{"a1":"a1", "a3": "b4", "c1": "c3"}', '123456789')

result = sheet_read_cells('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzTl', '{"a1":"a1", "a3": "b4", "c1": "c3"}')

status = get(result, 'status')

How to work through your account

By default, the designer works with its own service accounts to access your tables. Therefore you need to give access to the edit link.

To ensure sufficient security, you can use personal keys with authentication data.

Google Tables has a limit on the number of queries per unit of time. You can use your account to avoid the limits.

To do this in the project settings in "Project Constants", you need to add the variable sheet_json_keys with an array of your keys.

It can contain both json keys from the file and the address url to the key file.

The json key from the file - get the file with the key (read below), open any text editor and copy the content and add to the array.

Url address to key file is the easiest way to get such url - upload data file to constructor.

To do this, you need to create a block not status, in the attachment - download the file with service data (how to get it - read below). Then, right click on the file name and select Copy link address.

Four examples of the variable sheet_json_keys:

  • ["url address to key file", "url address to key file 2"]

  • ["url to key file", "url to key file 2", {json key from file}, {json key from file}]

  • [{json key from file}] (the key in the screenshot is shortened, the real key is much larger)

  • ["url address to key file"]

How to Remove a Cell Range

It is carried out with the help of the function:

sheet_remove_range(sheet_id, del_range, worksheet_name_or_id_or_index=None)

sheet_id is your Google Table ID.

del_range - as "A1:B2" - a range of cells to be erased

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number (starting from 1) or sheet identifier If there is no problem in executing the query, the answer comes dictionary {"status":true} or error description {"status":false,"err":"Error or description"}

Example: remove cells A1, B1, A2, B2 from the first sheet

result = sheet_remove_range('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzT', 'A1:B2')

How to completely delete a row with offset

It is carried out with the help of the function:

sheet_remove_row(sheet_id, row_number, worksheet_name_or_id_or_index=None)

sheet_id is your Google Table ID.

row_number - number of string to erase (numbering with 1)

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number (starting from 1) or sheet identifier

If there is no problem in executing the query, the answer comes dictionary {"status":true} or error description {"status":false,"err":"Error or description"}

Example: delete row number 14 from the first sheet

result = sheet_remove_row('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzT', '14')

How to completely remove column, with offset

It is carried out with the help of the function:

sheet_remove_col(sheet_id, col_number, worksheet_name_or_id_or_index=None) sheet_id is your Google Table ID.

col_number- the number of the column to delete (numbering with 1)

worksheet_name_or_id_or_index - optional parameter, sheet name, sequence number (starting from 1) or sheet identifier

If there is no problem in executing the query, the answer comes dictionary {"status":true} or error description {"status":false,"err":"Error or description"}

Example: remove the 6th column from the first sheet

result = sheet_remove_col('12sSVR3Wk-1kNb9CsjyJ2gjLb_PiRl5DhbF4YcD1VzT', '6')

How to Search the Text in a Table

Four algorithm search modes are available for each search option:

  • perfect match - F

  • by keywords - K (Latin)

  • Levenstein’s distance - 80 (value from 1 to 100 level "similarity")

  • using the regular expression - R

To select one of the modes, you must pass the value to the corresponding method field (detailed example in the function sheet_search_in_col_return_cell).

How to search by column and print text from the specified column in the same row

Searching the column will return the first value found.

The column search is performed using the function:

sheet_search_in_col_return_cell(sheet_id, query, col_number, return_col, algorithm, worksheet_name_or_index=None)

sheet_id is your Google Table ID.

query - search query, what you need to find

col_number - number of column in which to search (numbering with 1)

return_col - column number from which to return value

algorithm - algorithm - algorithm of search (F - total match, K - presence of keywords, R - regular expression, 1-100 - percentage of similarity (more details above))

worksheet_name_or_id_or_index - optional parameter, sheet name or sheet ID

Example use Consider all search algorithms using this function.

Condition: Search in sheet with name Sheet 1, in column 2 cell with phrase "search query", if found, the value in this row from column 5 will return

1.Full match - F

sheet_search_in_col_return_cell("#{sheet_id}", "search query", 5, 1, "F", "workSheet1")

If you search in the first sheet, then a sufficient set of parameters:

sheet_search_in_col_return_cell("#{sheet_id}", "search query", 2, 5)

Search for the phrase "Hello World" in workSheet1 in 5 column (column E). Request the cell contents of the same row in 1 column (column A):

2.By Keywords - K (Latin) The conditions are the same as in the first example.

sheet_search_in_col_return_cell("#{sheet_id}", "search query", 2, 5, "K", "List1")

For example, if the column has a cell with the text: "The search request is sent to the service", this cell will be found because the search query is included in the phrase: "The search request is passed to the service"

Search for the keyword "world" in workSheet1 in 2 column (column B). Query the cell contents of the same row in 1 column (column A):

3.Levenstein distance

The conditions are the same as in the first example.

sheet_search_in_col_return_cell("#{sheet_id}", "search query", 2, 5, "80", "List1")

In the example, the value given is 80 - this is the minimum threshold of similarity, register is not taken into account (the value can be from 1 to 100). Returns the best match. Search for the phrase "Hi World" (we have written with errors "hi word") in sheet1 in 2 column (column B). Query the cell contents of the same row in column 2 (column B)

4.Using the regular expression - R

Condition: Search in a sheet with the name Sheet 1, in column 5 cell by regular expression [ d d d$" (the value in the cell consists of 3 digits), if one is found, the value in this row in column 3 will return

sheet_search_in_col_return_cell("#{sheet_id}", "^\d\d\d$", 5, 3, "R", "workSheet1")

Note that the regular expression itself is passed as a second parameter instead of a phrase to search for.

If there is no problem with the query execution, the dictionary containing the status and the result of the search comes back:

status - search result

find - value from selected column

row - row number

col - column number

cell - full name of cell If an error occurs, false status will return and error description {"status":false,"err":"Error or description"}

How to Search by Column and Output Text from Whole Row

It is carried out with the help of the function:

sheet_search_in_col_return_row(sheet_id, query, col_number, algorithm, worksheet_name_or_index=None)

sheet_id is your Google Table ID.

query - search query, what you need to find

col_number - number of column in which to search (numbering with 1)

algorithm - algorithm - algorithm of search (F - total match, K - presence of keywords, R - regular expression, 1-100 - percentage of similarity (more details above))

worksheet_name_or_id_or_index - optional parameter, sheet name or sheet ID

Returns the string of the first value found

Example:

result = sheet_search_in_col_return_row("#{sheet_id}", "111", '2', 'F')

search for row 111 in column 2 and return the entire row.

If there are no problems while executing the query, a dictionary containing the status and all cells with values comes back

status - search result

row_data - dictionary with string data

row - row number

col - column number

cell - full name of cell If an error occurs, false status will return and error description {"status":false,"err":"Error or description"}

How to search by column and display all values

Use function to find all specified values in column sheet_search_in_col_return_cells_list(sheet_id, query, col_number, return_col, algorithm, worksheet_name_or_index=None)

sheet_id is your Google Table ID.

query - search query, what you need to find

col_number - number of column in which to search (numbering with 1)

algorithm - algorithm - algorithm of search (F - total match, K - presence of keywords, R - regular expression, 1-100 - percentage of similarity (more details above))

worksheet_name_or_id_or_index - optional parameter, sheet name or sheet ID Example:

result = sheet_search_in_col_return_cells_list("#{sheet_id}", "111", '2', '1', "F")

If there are no problems while executing the query, a dictionary containing the status and all cells with values comes back

status - search result

rows_index - array with numbers of found rows

quantity - number of rows found

list - a string with all values from the selected column

If an error occurs, false status will return and error description {"status":false,"err":"Error or description"}

How to search multiple columns and display all values

If you need to search multiple columns at once and get a list of values from the column in the rows where all values will be found, you should use the following function

sheet_search_in_multiple_cols_return_list(sheet_id, columns, return_col, with_index, delimiter, algorithm, worksheet_name_or_index=None)

sheet_id is your Google Table ID.

columns - search query, what you need to find

return_col - the number of the column in which to search (numbering with 1)

with_index - index or number in the list of found values (0 - numbering (1,2,3,...); 1 - string index; "" - list of values with new row without indexes and numbering)

delimiter - delimiter between index and value

algorithm - algorithm - algorithm of search (F - total match, K - presence of keywords, R - regular expression, 1-100 - percentage of similarity (more details above))

worksheet_name_or_id_or_index - optional parameter, sheet name or sheet ID

Example:

result = sheet_search_in_multiple_cols_return_list("#{sheet_id}", '{"2":"111", "4": "111"}', '1', '1', ' - ', "F") status = get(result, 'status')

If there are no problems while executing the query, a dictionary containing the status and all cells with values comes back

{"status":true,"rows_index":[10,5],"quantity":2,"list":"10 - next\n5 - believe\n"}

status - search result

rows_index - array with numbers of found rows

quantity - number of rows found

list - a string with all values from the selected column If an error occurs, false status will return and error description {"status":false,"err":"Error or description"}

How to Search Multiple Columns and Output Text From Whole Row

If you need to search for several columns at once and get the first found string, you need to use the following function

sheet_search_in_multiple_cols_return_row(sheet_id, columns, algorithm, worksheet_name_or_index=None)

sheet_id is your Google Table ID.

columns - search query, what you need to find

algorithm - algorithm - algorithm of search (F - total match, K - presence of keywords, R - regular expression, 1-100 - percentage of similarity (more details above))

worksheet_name_or_id_or_index - optional parameter, sheet name or sheet ID Example

result = sheet_search_in_multiple_cols_return_row("#{sheet_id}", '{"2":"111", "4": "111"}', "F")

status = get(result, 'status')

If there are no problems while executing the query, a dictionary containing the status and all cells with values comes back

{"status":true,"rows_index":[10,5],"quantity":2,"row_data": "1":"next","2":"111","3":"","4":"111","5":"sefdef"},"row":10}

status - search result

rows_index - array with numbers of found rows

quantity - number of rows found

list - a string with all values from the selected column

If an error occurs, false status will return and error description {"status":false,"err":"Error or description"}

Last updated