پرش به مستندات
Python

openemail.chats

هر متد در این فضای نام: امضا، پارامترها، آنچه برمی‌گرداند و یک نمونه.

متدها

The conversations held with the assistant in the app: list and search them, read one, rename it and delete it. Only the workspace owner reaches them.

chats.list()

List the assistant chats

محدوده‌های دسترسیthreads:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
def list(    *,    limit: int | None = None,    cursor: str | None = None,    q: str | None = None,    sort: ChatSort | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> Page[ChatResource]

Returns one page of the conversations held with the assistant in the app, newest first, as its Chats page lists them, each with its title, how many messages it holds and when it last changed.

Only the workspace owner reaches the chats: an API key, or an access token the owner connected with every address. A token acting for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

پارامترها

limitint

Page size, from 1 to 100. The server defaults to 25.

cursorstr

The nextCursor of the previous page. Leave it out for the first page.

qstr

Searches the titles.

sortChatSort

newest (the default) or oldest by the last change, or title. A cursor carries on in the order it was handed out in.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

خروجی

Page[ChatResource], a dict with items, hasMore and nextCursor. Each item has id, title, kind, messageCount and updatedAt.

نمونه

from openemail import openemail page = openemail.chats.list(q='invoices', limit=10) for chat in page['items']:    print(chat['title'], chat['messageCount'], chat['updatedAt']) print('More to read:', page['hasMore'])

نکته‌ها

همچنین در دسترس در

API
GET /chats
TypeScript
chats.list()
Ruby
chats.list
CLI
openemail chats list

chats.list_all()

Collect every chat into one list

محدوده‌های دسترسیthreads:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
def list_all(    *,    limit: int | None = None,    cursor: str | None = None,    q: str | None = None,    sort: ChatSort | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> builtins.list[ChatResource]

Walks every page of list and returns every chat in one list, in the order sort= names. One request per page, with the same filters on each.

پارامترها

limitint

Page size for each request, from 1 to 100. The server defaults to 25.

cursorstr

Starts the walk after this cursor instead of the first page.

qstr

Searches the titles.

sortChatSort

newest (the default) or oldest by the last change, or title. A cursor carries on in the order it was handed out in.

api_keystr

Overrides the client API key for every page of this walk.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

خروجی

list[ChatResource] holding every chat.

نمونه

from openemail import openemail chats = openemail.chats.list_all() print(len(chats), 'chats holding', sum(chat['messageCount'] for chat in chats), 'messages')

نکته‌ها

  • If any page fails, the call raises and the rows already fetched are discarded.

همچنین در دسترس در

API
GET /chats
TypeScript
chats.listAll()
Ruby
chats.list_all

chats.iterate()

Stream the chats one at a time

محدوده‌های دسترسیthreads:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
def iterate(    *,    limit: int | None = None,    cursor: str | None = None,    q: str | None = None,    sort: ChatSort | None = None,    api_key: str | None = None,    timeout: float | None = None,) -> Iterator[ChatResource]

Returns a generator that yields one chat at a time, in the order sort= names, and requests the next page only once the current one is drained. Nothing is fetched until you loop over it, and breaking out of the loop stops the requests.

پارامترها

limitint

Page size for each request, from 1 to 100. The server defaults to 25.

cursorstr

Starts the walk after this cursor instead of the first page.

qstr

Searches the titles.

sortChatSort

newest (the default) or oldest by the last change, or title. A cursor carries on in the order it was handed out in.

api_keystr

Overrides the client API key for every page of this walk.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

خروجی

Iterator[ChatResource], a generator yielding one chat per step.

نمونه

from openemail import openemail for chat in openemail.chats.iterate(sort='title'):    print(chat['title'], chat['messageCount'])

نکته‌ها

  • Each page is one request, so a long walk makes many.

همچنین در دسترس در

API
GET /chats
TypeScript
chats.iterate()
Ruby
chats.iterate

chats.get()

Retrieve a chat

محدوده‌های دسترسیthreads:read
امضای متد
def get(    id: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> ChatResource

Returns one chat with the assistant by its id: its title, how many messages it holds and when it last changed.

Only the workspace owner reaches the chats: an API key, or an access token the owner connected with every address. A token acting for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

پارامترها

idstrالزامی

The chat id from list.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

خروجی

ChatResource with id, title, kind, messageCount and updatedAt.

نمونه

from openemail import openemail chat = openemail.chats.get('8f3c2a71-5e9d-4b06-a1c4-7d2e9f0b3a65') print(chat['title'], chat['messageCount'], chat['updatedAt'])

نکته‌ها

  • An unknown id is a 404.

همچنین در دسترس در

API
GET /chats/{id}
TypeScript
chats.get()
Ruby
chats.get
CLI
openemail chats get

chats.rename()

Rename a chat

محدوده‌های دسترسیthreads:write
امضای متد
def rename(    id: str,    title: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> ChatResource

Gives a chat with the assistant a new title, up to 120 characters, and returns the chat as it is now.

Only the workspace owner reaches the chats: an API key, or an access token the owner connected with every address. A token acting for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

پارامترها

idstrالزامی

The chat id from list.

titlestrالزامی

The new title, from 1 to 120 characters.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

خروجی

ChatResource with the new title.

نمونه

from openemail import openemail chat = openemail.chats.rename('8f3c2a71-5e9d-4b06-a1c4-7d2e9f0b3a65', 'Quarterly invoices') print(chat['id'], chat['title'])

نکته‌ها

  • An unknown id is a 404.

  • Retried automatically on network failure, since the same title sent twice changes nothing.

همچنین در دسترس در

API
PATCH /chats/{id}
TypeScript
chats.rename()
Ruby
chats.rename
CLI
openemail chats rename

chats.delete()

Delete a chat

محدوده‌های دسترسیthreads:write
امضای متد
def delete(    id: str,    *,    api_key: str | None = None,    timeout: float | None = None,) -> DeletedChatResource

Deletes a chat with the assistant and every message in it, for good. Nothing the assistant did in the mailbox is undone.

Only the workspace owner reaches the chats: an API key, or an access token the owner connected with every address. A token acting for a member is 403 owner_only, and a key or token limited to particular addresses or domains is 422 capability_unsupported.

پارامترها

idstrالزامی

The chat id from list.

api_keystr

Overrides the client's API key for this call only.

timeoutfloat

Seconds this call may take, the response included, before it raises OpenEmailNetworkError with is_timeout. It overrides the client's timeout for this call, and 0 turns the limit off.

خروجی

DeletedChatResource with object set to chat, the id and deleted set to True.

نمونه

from openemail import OpenEmailApiError, openemail try:    removed = openemail.chats.delete('8f3c2a71-5e9d-4b06-a1c4-7d2e9f0b3a65')except OpenEmailApiError as error:    if not error.is_not_found:        raise     print('That chat is already gone')else:    print(removed['id'], removed['deleted'])

نکته‌ها

  • An unknown id is a 404, and so is a second call for the same chat.

  • The SDK does not retry it.

همچنین در دسترس در

API
DELETE /chats/{id}
TypeScript
chats.delete()
Ruby
chats.delete
CLI
openemail chats delete