* 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
30 KiB
API Commands and Responses
This file is generated automatically.
- APIAddMember
- APIJoinGroup
- APIAcceptMember
- APIMembersRole
- APIBlockMembersForAll
- APIRemoveMembers
- APILeaveGroup
- APIListMembers
- APINewGroup
- APIUpdateGroupProfile
- ShowActiveUser
- CreateActiveUser
- ListUsers
- APISetActiveUser
- APIDeleteUser
- APIUpdateProfile
- APISetContactPrefs
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.
- type: "userContactLinkCreated"
- user: User
- connLinkContact: CreatedConnLink
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.
- type: "userContactLink"
- user: User
- contactLink: UserContactLink
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.
- type: "userProfileUpdated"
- user: User
- fromProfile: Profile
- toProfile: Profile
- updateSummary: UserProfileUpdateSummary
APISetAddressSettings
Set bot address settings.
Network usage: interactive.
Parameters:
- userId: int64
- settings: AddressSettings
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.
- type: "userContactLinkUpdated"
- user: User
- contactLink: UserContactLink
Message commands
Commands to send, update, delete, moderate messages and set message reactions
APISendMessages
Send messages.
Network usage: background.
Parameters:
- sendRef: ChatRef
- liveMessage: bool
- ttl: int?
- composedMessages: [ComposedMessage]
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:
- chatRef: ChatRef
- chatItemId: int64
- liveMessage: bool
- updatedMessage: UpdatedMessage
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.
- type: "chatCmdError"
- chatError: ChatError
Errors:
- InvalidChatItemUpdate: Not user's message or cannot be edited.
APIDeleteChatItem
Delete message.
Network usage: background.
Parameters:
- chatRef: ChatRef
- chatItemIds: [int64]
- deleteMode: CIDeleteMode
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:
- chatRef: ChatRef
- chatItemId: int64
- add: bool
- reaction: MsgReaction
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.
- type: "chatItemReaction"
- user: User
- added: bool
- reaction: ACIReaction
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.
- type: "rcvFileAcceptedSndCancelled"
- user: User
- rcvFileTransfer: RcvFileTransfer
CancelFile
Cancel file.
Network usage: background.
Parameters:
- fileId: int64
Syntax:
/fcancel <fileId>
'/fcancel ' + fileId // JavaScript
'/fcancel ' + str(fileId) # Python
Responses:
SndFileCancelled: Cancelled sending file.
- type: "sndFileCancelled"
- user: User
- chatItem_: AChatItem?
- fileTransferMeta: FileTransferMeta
- sndFileTransfers: [SndFileTransfer]
RcvFileCancelled: Cancelled receiving file.
- type: "rcvFileCancelled"
- user: User
- chatItem_: AChatItem?
- rcvFileTransfer: RcvFileTransfer
ChatCmdError: Command error.
- type: "chatCmdError"
- chatError: ChatError
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:
- groupId: int64
- contactId: int64
- memberRole: GroupMemberRole
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.
- type: "sentGroupInvitation"
- user: User
- groupInfo: GroupInfo
- contact: Contact
- member: GroupMember
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:
- groupId: int64
- groupMemberId: int64
- memberRole: GroupMemberRole
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.
- type: "memberAccepted"
- user: User
- groupInfo: GroupInfo
- member: GroupMember
ChatCmdError: Command error.
- type: "chatCmdError"
- chatError: ChatError
Errors:
- GroupMemberNotActive: Member is not connected yet.
APIMembersRole
Set members role. Requires Admin role.
Network usage: background.
Parameters:
- groupId: int64
- groupMemberIds: [int64]
- memberRole: GroupMemberRole
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.
- type: "membersRoleUser"
- user: User
- groupInfo: GroupInfo
- members: [GroupMember]
- toRole: GroupMemberRole
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.
- type: "membersBlockedForAllUser"
- user: User
- groupInfo: GroupInfo
- members: [GroupMember]
- blocked: bool
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.
- type: "userDeletedMembers"
- user: User
- groupInfo: GroupInfo
- members: [GroupMember]
- withMessages: bool
ChatCmdError: Command error.
- type: "chatCmdError"
- chatError: ChatError
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.
APINewGroup
Create group.
Network usage: no.
Parameters:
- userId: int64
- incognito: bool
- groupProfile: GroupProfile
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:
- groupId: int64
- groupProfile: GroupProfile
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.
- type: "groupUpdated"
- user: User
- fromGroup: GroupInfo
- toGroup: GroupInfo
- member_: GroupMember?
Group link commands
These commands can be used by bots that manage multiple public groups
APICreateGroupLink
Create group link.
Network usage: interactive.
Parameters:
- groupId: int64
- memberRole: GroupMemberRole
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:
- groupId: int64
- memberRole: GroupMemberRole
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.
APIDeleteGroupLink
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.
APIGetGroupLink
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.
- type: "invitation"
- user: User
- connLinkInvitation: CreatedConnLink
- connection: PendingContactConnection
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.
- type: "connectionPlan"
- user: User
- connLink: CreatedConnLink
- connectionPlan: ConnectionPlan
APIConnect
Connect via SimpleX link. The link can be 1-time invitation link, contact address or group link
Network usage: interactive.
Parameters:
- userId: int64
- incognito: bool
- connLink_: CreatedConnLink?
Syntax:
/_connect <userId> <str(connLink_)>
'/_connect ' + userId + ' ' + connLink_.toString() // JavaScript
'/_connect ' + str(userId) + ' ' + str(connLink_) # Python
Responses:
SentConfirmation: Confirmation sent to one-time invitation.
- type: "sentConfirmation"
- user: User
- connection: PendingContactConnection
- customUserProfile: Profile?
ContactAlreadyExists: Contact already exists.
SentInvitation: Invitation sent to contact address.
- type: "sentInvitation"
- user: User
- connection: PendingContactConnection
- customUserProfile: Profile?
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.
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.
- type: "contactRequestRejected"
- user: User
- contactRequest: UserContactRequest
- contact_: Contact?
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.
- type: "groupsList"
- user: User
- groups: [GroupInfoSummary]
APIDeleteChat
Delete chat.
Network usage: background.
Parameters:
- chatRef: ChatRef
- chatDeleteMode: ChatDeleteMode
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.
- type: "contactConnectionDeleted"
- user: User
- connection: PendingContactConnection
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:
- newUser: NewUser
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.
- type: "usersList"
- users: [UserInfo]
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:
- userId: int64
- profile: Profile
Syntax:
/_profile <userId> <json(profile)>
'/_profile ' + userId + ' ' + JSON.stringify(profile) // JavaScript
'/_profile ' + str(userId) + ' ' + json.dumps(profile) # Python
Response:
UserProfileUpdated: User profile updated.
- type: "userProfileUpdated"
- user: User
- fromProfile: Profile
- toProfile: Profile
- updateSummary: UserProfileUpdateSummary
APISetContactPrefs
Configure chat preference overrides for the contact.
Network usage: background.
Parameters:
- contactId: int64
- preferences: Preferences
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.