Files
simplex-chat/bots/api/COMMANDS.md
Evgeny 4811d663e6 rfc: bot messages and buttons, core: command markdown, supported commands in profile preferences, chat sessions preference, peer type field in profile to identify bots (#5360)
* rfc: bot messages and buttons

* update

* update bot rfc

* core: add bot commands to chat preferences and peer type to profile

* update postgresql schema

* update query plans

* chat sessions preference

* markdown for bot commands

* schema

* core: file preference, options to create bot from CLI

* core: different command type

* ios: commands menu

* update types

* update ios

* improve command markdown

* core, ios: update types

* android, desktop: clickable commands in messages in chats with bots

* android, desktop: commands menu

* command menu button, bot icon

* ios: connect flow for bots

* android, desktop: connect flow for bots

* icon

* CLI commands to view and set commands, remove "hidden" property of command, bot api docs

* corrections

* fix inheriting profile preferences to business groups

* note on business address

* ios: export localizations

* fix test

* commands to set file preference on user/contact, tidy up layout and display of command and attachment buttons
2025-08-07 11:13:35 +01:00

30 KiB

API Commands and Responses

This file is generated automatically.

Address commands

Message commands

File commands

Group commands

Group link commands

Connection commands

Chat commands

User profile commands


Address commands

Bots can use these commands to automatically check and create address when initialized

APICreateMyAddress

Create bot address.

Network usage: interactive.

Parameters:

  • userId: int64

Syntax:

/_address <userId>
'/_address ' + userId // JavaScript
'/_address ' + str(userId) # Python

Response:

UserContactLinkCreated: User contact address created.


APIDeleteMyAddress

Delete bot address.

Network usage: background.

Parameters:

  • userId: int64

Syntax:

/_delete_address <userId>
'/_delete_address ' + userId // JavaScript
'/_delete_address ' + str(userId) # Python

Response:

UserContactLinkDeleted: User contact address deleted.

  • type: "userContactLinkDeleted"
  • user: User

APIShowMyAddress

Get bot address and settings.

Network usage: no.

Parameters:

  • userId: int64

Syntax:

/_show_address <userId>
'/_show_address ' + userId // JavaScript
'/_show_address ' + str(userId) # Python

Response:

UserContactLink: User contact address.


APISetProfileAddress

Add address to bot profile.

Network usage: interactive.

Parameters:

  • userId: int64
  • enable: bool

Syntax:

/_profile_address <userId> on|off
'/_profile_address ' + userId + ' ' + (enable ? 'on' : 'off') // JavaScript
'/_profile_address ' + str(userId) + ' ' + ('on' if enable else 'off') # Python

Response:

UserProfileUpdated: User profile updated.


APISetAddressSettings

Set bot address settings.

Network usage: interactive.

Parameters:

Syntax:

/_address_settings <userId> <json(settings)>
'/_address_settings ' + userId + ' ' + JSON.stringify(settings) // JavaScript
'/_address_settings ' + str(userId) + ' ' + json.dumps(settings) # Python

Response:

UserContactLinkUpdated: User contact address updated.


Message commands

Commands to send, update, delete, moderate messages and set message reactions

APISendMessages

Send messages.

Network usage: background.

Parameters:

Syntax:

/_send <str(sendRef)>[ live=on][ ttl=<ttl>] json <json(composedMessages)>
'/_send ' + sendRef.toString() + (liveMessage ? ' live=on' : '') + (ttl ? ' ttl=' + ttl : '') + ' json ' + JSON.stringify(composedMessages) // JavaScript
'/_send ' + str(sendRef) + (' live=on' if liveMessage else '') + ((' ttl=' + str(ttl)) if ttl is not None else '') + ' json ' + json.dumps(composedMessages) # Python

Response:

NewChatItems: New messages.


APIUpdateChatItem

Update message.

Network usage: background.

Parameters:

Syntax:

/_update item <str(chatRef)> <chatItemId>[ live=on] json <json(updatedMessage)>
'/_update item ' + chatRef.toString() + ' ' + chatItemId + (liveMessage ? ' live=on' : '') + ' json ' + JSON.stringify(updatedMessage) // JavaScript
'/_update item ' + str(chatRef) + ' ' + str(chatItemId) + (' live=on' if liveMessage else '') + ' json ' + json.dumps(updatedMessage) # Python

Responses:

ChatItemUpdated: Message updated.

ChatItemNotChanged: Message not changed.

ChatCmdError: Command error.

Errors:

  • InvalidChatItemUpdate: Not user's message or cannot be edited.

APIDeleteChatItem

Delete message.

Network usage: background.

Parameters:

Syntax:

/_delete item <str(chatRef)> <chatItemIds[0]>[,<chatItemIds[1]>...] broadcast|internal|internalMark
'/_delete item ' + chatRef.toString() + ' ' + chatItemIds.join(',') + ' ' + deleteMode // JavaScript
'/_delete item ' + str(chatRef) + ' ' + ','.join(map(str, chatItemIds)) + ' ' + str(deleteMode) # Python

Response:

ChatItemsDeleted: Messages deleted.

  • type: "chatItemsDeleted"
  • user: User
  • chatItemDeletions: [ChatItemDeletion]
  • byUser: bool
  • timed: bool

APIDeleteMemberChatItem

Moderate message. Requires Moderator role (and higher than message author's).

Network usage: background.

Parameters:

  • groupId: int64
  • chatItemIds: [int64]

Syntax:

/_delete member item #<groupId> <chatItemIds[0]>[,<chatItemIds[1]>...]
'/_delete member item #' + groupId + ' ' + chatItemIds.join(',') // JavaScript
'/_delete member item #' + str(groupId) + ' ' + ','.join(map(str, chatItemIds)) # Python

Response:

ChatItemsDeleted: Messages deleted.

  • type: "chatItemsDeleted"
  • user: User
  • chatItemDeletions: [ChatItemDeletion]
  • byUser: bool
  • timed: bool

APIChatItemReaction

Add/remove message reaction.

Network usage: background.

Parameters:

Syntax:

/_reaction <str(chatRef)> <chatItemId> on|off <json(reaction)>
'/_reaction ' + chatRef.toString() + ' ' + chatItemId + ' ' + (add ? 'on' : 'off') + ' ' + JSON.stringify(reaction) // JavaScript
'/_reaction ' + str(chatRef) + ' ' + str(chatItemId) + ' ' + ('on' if add else 'off') + ' ' + json.dumps(reaction) # Python

Response:

ChatItemReaction: Message reaction.


File commands

Commands to receive and to cancel files. Files are sent as part of the message, there are no separate commands to send files.

ReceiveFile

Receive file.

Network usage: no.

Parameters:

  • fileId: int64
  • userApprovedRelays: bool
  • storeEncrypted: bool?
  • fileInline: bool?
  • filePath: string?

Syntax:

/freceive <fileId>[ approved_relays=on][ encrypt=on|off][ inline=on|off][ <filePath>]
'/freceive ' + fileId + (userApprovedRelays ? ' approved_relays=on' : '') + (typeof storeEncrypted == 'boolean' ? ' encrypt=' + (storeEncrypted ? 'on' : 'off') : '') + (typeof fileInline == 'boolean' ? ' inline=' + (fileInline ? 'on' : 'off') : '') + (filePath ? ' ' + filePath : '') // JavaScript
'/freceive ' + str(fileId) + (' approved_relays=on' if userApprovedRelays else '') + ((' encrypt=' + ('on' if storeEncrypted else 'off')) if storeEncrypted is not None else '') + ((' inline=' + ('on' if fileInline else 'off')) if fileInline is not None else '') + ((' ' + filePath) if filePath is not None else '') # Python

Responses:

RcvFileAccepted: File accepted to be received.

RcvFileAcceptedSndCancelled: File accepted, but no longer sent.


CancelFile

Cancel file.

Network usage: background.

Parameters:

  • fileId: int64

Syntax:

/fcancel <fileId>
'/fcancel ' + fileId // JavaScript
'/fcancel ' + str(fileId) # Python

Responses:

SndFileCancelled: Cancelled sending file.

RcvFileCancelled: Cancelled receiving file.

ChatCmdError: Command error.

Errors:

  • FileCancel: Cannot cancel file.

Group commands

Commands to manage and moderate groups. These commands can be used with business chats as well - they are groups. E.g., a common scenario would be to add human agents to business chat with the customer who connected via business address.

APIAddMember

Add contact to group. Requires bot to have Admin role.

Network usage: interactive.

Parameters:

Syntax:

/_add #<groupId> <contactId> observer|author|member|moderator|admin|owner
'/_add #' + groupId + ' ' + contactId + ' ' + memberRole // JavaScript
'/_add #' + str(groupId) + ' ' + str(contactId) + ' ' + str(memberRole) # Python

Response:

SentGroupInvitation: Group invitation sent.


APIJoinGroup

Join group.

Network usage: interactive.

Parameters:

  • groupId: int64

Syntax:

/_join #<groupId>
'/_join #' + groupId // JavaScript
'/_join #' + str(groupId) # Python

Response:

UserAcceptedGroupSent: User accepted group invitation.


APIAcceptMember

Accept group member. Requires Admin role.

Network usage: background.

Parameters:

Syntax:

/_accept member #<groupId> <groupMemberId> observer|author|member|moderator|admin|owner
'/_accept member #' + groupId + ' ' + groupMemberId + ' ' + memberRole // JavaScript
'/_accept member #' + str(groupId) + ' ' + str(groupMemberId) + ' ' + str(memberRole) # Python

Responses:

MemberAccepted: Member accepted to group.

ChatCmdError: Command error.

Errors:

  • GroupMemberNotActive: Member is not connected yet.

APIMembersRole

Set members role. Requires Admin role.

Network usage: background.

Parameters:

Syntax:

/_member role #<groupId> <groupMemberIds[0]>[,<groupMemberIds[1]>...] observer|author|member|moderator|admin|owner
'/_member role #' + groupId + ' ' + groupMemberIds.join(',') + ' ' + memberRole // JavaScript
'/_member role #' + str(groupId) + ' ' + ','.join(map(str, groupMemberIds)) + ' ' + str(memberRole) # Python

Response:

MembersRoleUser: Members role changed by user.


APIBlockMembersForAll

Block members. Requires Moderator role.

Network usage: background.

Parameters:

  • groupId: int64
  • groupMemberIds: [int64]
  • blocked: bool

Syntax:

/_block #<groupId> <groupMemberIds[0]>[,<groupMemberIds[1]>...] blocked=on|off
'/_block #' + groupId + ' ' + groupMemberIds.join(',') + ' blocked=' + (blocked ? 'on' : 'off') // JavaScript
'/_block #' + str(groupId) + ' ' + ','.join(map(str, groupMemberIds)) + ' blocked=' + ('on' if blocked else 'off') # Python

Response:

MembersBlockedForAllUser: Members blocked for all by admin.


APIRemoveMembers

Remove members. Requires Admin role.

Network usage: background.

Parameters:

  • groupId: int64
  • groupMemberIds: [int64]
  • withMessages: bool

Syntax:

/_remove #<groupId> <groupMemberIds[0]>[,<groupMemberIds[1]>...][ messages=on]
'/_remove #' + groupId + ' ' + groupMemberIds.join(',') + (withMessages ? ' messages=on' : '') // JavaScript
'/_remove #' + str(groupId) + ' ' + ','.join(map(str, groupMemberIds)) + (' messages=on' if withMessages else '') # Python

Responses:

UserDeletedMembers: Members deleted.

ChatCmdError: Command error.

Errors:

  • GroupMemberNotFound: Group member not found.

APILeaveGroup

Leave group.

Network usage: background.

Parameters:

  • groupId: int64

Syntax:

/_leave #<groupId>
'/_leave #' + groupId // JavaScript
'/_leave #' + str(groupId) # Python

Response:

LeftMemberUser: User left group.


APIListMembers

Get group members.

Network usage: no.

Parameters:

  • groupId: int64

Syntax:

/_members #<groupId>
'/_members #' + groupId // JavaScript
'/_members #' + str(groupId) # Python

Response:

GroupMembers: Group members.

  • type: "groupMembers"
  • user: User
  • group: Group

APINewGroup

Create group.

Network usage: no.

Parameters:

Syntax:

/_group <userId>[ incognito=on] <json(groupProfile)>
'/_group ' + userId + (incognito ? ' incognito=on' : '') + ' ' + JSON.stringify(groupProfile) // JavaScript
'/_group ' + str(userId) + (' incognito=on' if incognito else '') + ' ' + json.dumps(groupProfile) # Python

Response:

GroupCreated: Group created.


APIUpdateGroupProfile

Update group profile.

Network usage: background.

Parameters:

Syntax:

/_group_profile #<groupId> <json(groupProfile)>
'/_group_profile #' + groupId + ' ' + JSON.stringify(groupProfile) // JavaScript
'/_group_profile #' + str(groupId) + ' ' + json.dumps(groupProfile) # Python

Response:

GroupUpdated: Group updated.


These commands can be used by bots that manage multiple public groups

Create group link.

Network usage: interactive.

Parameters:

Syntax:

/_create link #<groupId> observer|author|member|moderator|admin|owner
'/_create link #' + groupId + ' ' + memberRole // JavaScript
'/_create link #' + str(groupId) + ' ' + str(memberRole) # Python

Response:

GroupLinkCreated: Group link created.


APIGroupLinkMemberRole

Set member role for group link.

Network usage: no.

Parameters:

Syntax:

/_set link role #<groupId> observer|author|member|moderator|admin|owner
'/_set link role #' + groupId + ' ' + memberRole // JavaScript
'/_set link role #' + str(groupId) + ' ' + str(memberRole) # Python

Response:

GroupLink: Group link.


Delete group link.

Network usage: background.

Parameters:

  • groupId: int64

Syntax:

/_delete link #<groupId>
'/_delete link #' + groupId // JavaScript
'/_delete link #' + str(groupId) # Python

Response:

GroupLinkDeleted: Group link deleted.


Get group link.

Network usage: no.

Parameters:

  • groupId: int64

Syntax:

/_get link #<groupId>
'/_get link #' + groupId // JavaScript
'/_get link #' + str(groupId) # Python

Response:

GroupLink: Group link.


Connection commands

These commands may be used to create connections. Most bots do not need to use them - bot users will connect via bot address with auto-accept enabled.

APIAddContact

Create 1-time invitation link.

Network usage: interactive.

Parameters:

  • userId: int64
  • incognito: bool

Syntax:

/_connect <userId>[ incognito=on]
'/_connect ' + userId + (incognito ? ' incognito=on' : '') // JavaScript
'/_connect ' + str(userId) + (' incognito=on' if incognito else '') # Python

Response:

Invitation: One-time invitation.


APIConnectPlan

Determine SimpleX link type and if the bot is already connected via this link.

Network usage: interactive.

Parameters:

  • userId: int64
  • connectionLink: string?

Syntax:

/_connect plan <userId> <connectionLink>
'/_connect plan ' + userId + ' ' + connectionLink // JavaScript
'/_connect plan ' + str(userId) + ' ' + connectionLink # Python

Response:

ConnectionPlan: Connection link information.


APIConnect

Connect via SimpleX link. The link can be 1-time invitation link, contact address or group link

Network usage: interactive.

Parameters:

Syntax:

/_connect <userId> <str(connLink_)>
'/_connect ' + userId + ' ' + connLink_.toString() // JavaScript
'/_connect ' + str(userId) + ' ' + str(connLink_) # Python

Responses:

SentConfirmation: Confirmation sent to one-time invitation.

ContactAlreadyExists: Contact already exists.

  • type: "contactAlreadyExists"
  • user: User
  • contact: Contact

SentInvitation: Invitation sent to contact address.


APIAcceptContact

Accept contact request.

Network usage: interactive.

Parameters:

  • contactReqId: int64

Syntax:

/_accept <contactReqId>
'/_accept ' + contactReqId // JavaScript
'/_accept ' + str(contactReqId) # Python

Response:

AcceptingContactRequest: Contact request accepted.

  • type: "acceptingContactRequest"
  • user: User
  • contact: Contact

APIRejectContact

Reject contact request. The user who sent the request is not notified.

Network usage: no.

Parameters:

  • contactReqId: int64

Syntax:

/_reject <contactReqId>
'/_reject ' + contactReqId // JavaScript
'/_reject ' + str(contactReqId) # Python

Response:

ContactRequestRejected: Contact request rejected.


Chat commands

Commands to list and delete conversations.

APIListContacts

Get contacts.

Network usage: no.

Parameters:

  • userId: int64

Syntax:

/_contacts <userId>
'/_contacts ' + userId // JavaScript
'/_contacts ' + str(userId) # Python

Response:

ContactsList: Contacts.


APIListGroups

Get groups.

Network usage: no.

Parameters:

  • userId: int64
  • contactId_: int64?
  • search: string?

Syntax:

/_groups <userId>[ @<contactId_>][ <search>]
'/_groups ' + userId + (contactId_ ? ' @' + contactId_ : '') + (search ? ' ' + search : '') // JavaScript
'/_groups ' + str(userId) + ((' @' + str(contactId_)) if contactId_ is not None else '') + ((' ' + search) if search is not None else '') # Python

Response:

GroupsList: Groups.


APIDeleteChat

Delete chat.

Network usage: background.

Parameters:

Syntax:

/_delete <str(chatRef)> <str(chatDeleteMode)>
'/_delete ' + chatRef.toString() + ' ' + chatDeleteMode.toString() // JavaScript
'/_delete ' + str(chatRef) + ' ' + str(chatDeleteMode) # Python

Responses:

ContactDeleted: Contact deleted.

ContactConnectionDeleted: Connection deleted.

GroupDeletedUser: User deleted group.


User profile commands

Most bots don't need to use these commands, as bot profile can be configured manually via CLI or desktop client. These commands can be used by bots that need to manage multiple user profiles (e.g., the profiles of support agents).

ShowActiveUser

Get active user profile

Network usage: no.

Syntax:

/user

Response:

ActiveUser: Active user profile.

  • type: "activeUser"
  • user: User

CreateActiveUser

Create new user profile

Network usage: no.

Parameters:

Syntax:

/_create user <json(newUser)>
'/_create user ' + JSON.stringify(newUser) // JavaScript
'/_create user ' + json.dumps(newUser) # Python

Response:

ActiveUser: Active user profile.

  • type: "activeUser"
  • user: User

Errors:

  • UserExists: User or contact with this name already exists.
  • InvalidDisplayName: Invalid user display name.

ListUsers

Get all user profiles

Network usage: no.

Syntax:

/users

Response:

UsersList: Users.


APISetActiveUser

Set active user profile

Network usage: no.

Parameters:

  • userId: int64
  • viewPwd: string?

Syntax:

/_user <userId>[ <json(viewPwd)>]
'/_user ' + userId + (viewPwd ? ' ' + JSON.stringify(viewPwd) : '') // JavaScript
'/_user ' + str(userId) + ((' ' + json.dumps(viewPwd)) if viewPwd is not None else '') # Python

Response:

ActiveUser: Active user profile.

  • type: "activeUser"
  • user: User

Errors:

  • ChatNotStarted: Chat not started.

APIDeleteUser

Delete user profile.

Network usage: background.

Parameters:

  • userId: int64
  • delSMPQueues: bool
  • viewPwd: string?

Syntax:

/_delete user <userId> del_smp=on|off[ <json(viewPwd)>]
'/_delete user ' + userId + ' del_smp=' + (delSMPQueues ? 'on' : 'off') + (viewPwd ? ' ' + JSON.stringify(viewPwd) : '') // JavaScript
'/_delete user ' + str(userId) + ' del_smp=' + ('on' if delSMPQueues else 'off') + ((' ' + json.dumps(viewPwd)) if viewPwd is not None else '') # Python

Response:

CmdOk: Ok.

  • type: "cmdOk"
  • user_: User?

APIUpdateProfile

Update user profile.

Network usage: background.

Parameters:

Syntax:

/_profile <userId> <json(profile)>
'/_profile ' + userId + ' ' + JSON.stringify(profile) // JavaScript
'/_profile ' + str(userId) + ' ' + json.dumps(profile) # Python

Response:

UserProfileUpdated: User profile updated.


APISetContactPrefs

Configure chat preference overrides for the contact.

Network usage: background.

Parameters:

Syntax:

/_set prefs @<contactId> <json(preferences)>
'/_set prefs @' + contactId + ' ' + JSON.stringify(preferences) // JavaScript
'/_set prefs @' + str(contactId) + ' ' + json.dumps(preferences) # Python

Response:

ContactPrefsUpdated: Contact preferences updated.