Documentation

Prompt registration

The procedure to register prompts via REST.

Registration

You will need the method ai.prompt.register for registration. Below is an example on how to use it when adding a category of jokes.

BX24.callMethod(
	'ai.prompt.register',
	{
		category: ["livefeed","livefeed_comments"],
		code: 'rest_joke',
		icon: 'smile',
		prompt: 'Tell me a joke',
		translate: {"en":"A joke"}
	},
	function(result)
	{
		if(result.error())
		{
			console.error(result.error());
		}
		else
		{
			console.info(result.data());
		}
	}
);

Parameter overview from the example above:


Parameter Description Available from version
category Embedding location category. CoPilot can be embedded in a variety of completely different locations. List of such locations:
Embedding location category CoPilot is visible in this location
livefeed
(Feed, post)
When writing a post in Feed.
livefeed_comments
(Feed, comments)
When writing a comment to a single Feed post.
tasks
(tasks, text)
When handling a task description.
tasks_comments
(tasks, comments)
When writing a comment to one of tasks.
chat
(чат)
When writing a message in a direct or group chats.
mail
(почта)
When handling emails from personal mailbox.
mail_crm
(CRM email)
When handling CRM customer emails in details for deals, contacts and companies.
landing
(сайты)
When handling texts in B24 site builder.

The example above registers a new Feed's CoPilot new item (post and comment).

icon Icon code. You can find a suitable icon in the file copilot_icon_set.pdf.
prompt Prompt text. This text will be directly processed by the AI network (and won't be visible to user). You can use special formatting in the preprompt text: markers and conditions.
sort Sorting, indicated optionally. Responsible for item sorting.
translate Array with item translations to various languages. Ideally, supports a minimum set of languages: Language and Bitrix24 account specific language. Support for other languages is optional.
sort Sorting, indicated optionally. Responsible for item sorting.

That's it. After the command is executed, we will see a clickable CoPilot's item that may generate very funny jokes.


To continue, you may make this item as parent item with subitems (after this, parent item stops being clickable).

You need to add a parent section code parent_code to the original code, and also sort (optional), for items sorting.

BX24.callMethod(
	'ai.prompt.register',
	{
		category: ["livefeed","livefeed_comments"],
		code: 'rest_joke_wolf',
		icon: 'smile',
		prompt: 'Tell me a joke about a wolf',
		translate: {"en":"A joke about wolf",},
		parent_code: 'rest_joke',
		sort: 100
	},
	function(result)
	{
		if(result.error())
		{
			console.error(result.error());
		}
		else
		{
			console.info(result.data());
		}
	}
);

You may also add a subsection to already existing items. For this, you need to find out the code for this item and use the previous code. For example, you can find it when opening a Feed post. At this moment, system sends a command for getting information via CoPilot.


Purely visual categories or sections can be passed in the section parameter, equal to 'create' or 'edit' accordingly. No extra logic is added. Such sections are created for visual categorization only, the preprompt itself changes or creates the text.

Deleting

In case you no longer need a preprompt and you want to replace it, just execute the command ai.prompt.unregister:

BX24.callMethod(
	'ai.prompt.unregister',
	{
		code: 'rest_joke_wolf'
	},
	function(result)
	{
		if(result.error())
		{
			console.error(result.error());
		}
		else
		{
			console.info(result.data());
		}
	}
);

© «Bitrix24», 2001-2024