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

client.Knowledge

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

متدها

The notes, files and web pages the AI uses when it writes replies, drafts email and answers in the assistant, each kept for the whole workspace, one domain or one address: list and search them, add a note, a link or a file, change, read again and delete them, and see the levels and how much the plan allows. Review the notes the AI suggests and the questions nothing answers, settle duplicate and conflict flags, keep a site, sitemap, feed or Zendesk help center in step with connectors, draft a note from a conversation, and read how often the AI used it.

Knowledge.List

List one page of the knowledge base

محدوده‌های دسترسیknowledge:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
List(ctx context.Context, opts ...openemail.RequestOption) (*openemail.Page, error)

Returns one page of the knowledge base, newest first: the notes, files and web pages the AI uses when it writes replies, drafts email and answers in the assistant. Each item says where it sits, whether the AI can use it yet and how much text was read from it. ListAll collects every page and Iterate walks them lazily.

Every item sits at one level, its scope: an empty string for the whole workspace, @ and a domain for everything on that domain (@acme.com), or one address ([email protected]). The AI writing for an address reads that address, then its domain, then the whole workspace, the most specific first. level names the kind of level, workspace, domain or address.

status is queued or processing while the text is read and indexed, ready once the AI can use it, and failed with a failure when it could not be read. A key or an app limited to particular addresses sees the whole-workspace items and the items at its addresses and at their domains.

Each item also says how the AI uses it: uses counts the times it came up in a reply suggestion, a draft, the assistant or a search, with lastUsedAt the latest, and flags counts the open duplicate and conflict flags that name it. A link read again on a schedule has refreshDays and nextRefreshAt, a page kept by a connector names it in connectorId, and a note saved from a conversation names it in threadId.

پارامترها

openemail.WithScopestring

Keeps the items at exactly this level: @ and a domain such as @acme.com, or one address. An empty string is not sent, so ask for the whole-workspace items with level: 'workspace'.

openemail.WithLevelstring

Keeps one kind of level: workspace, domain or address.

openemail.WithKindstring

Keeps one kind of item: note, file or link.

openemail.WithStatus...string

Keeps one status: queued, processing, ready or failed.

openemail.WithPinnedbool

true keeps the pinned notes and false everything else.

openemail.WithQstring

Words in the title, the file name or the link, matched without regard to case or accents.

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

A *openemail.Page with Items, HasMore and NextCursor. Each item has id, kind, scope, level, title, url, fileName, mimeType, sizeBytes, pinned, status, failure, chunks, chars, origin, createdBy, createdAt, updatedAt, indexedAt, refreshDays, nextRefreshAt, connectorId, threadId, uses, lastUsedAt and flags.

نمونه

page, err := client.Knowledge.List(ctx, openemail.WithLevel("domain"), openemail.WithKind("file"))if err != nil {	return err} for _, item := range page.Items {	fmt.Println(item.String("scope"), item.String("title"), item.String("status"))} fmt.Println(page.HasMore, page.NextCursor)

نکته‌ها

  • Needs knowledge:read, which knowledge:write includes.

  • The cursor is opaque. One this list did not hand out is a 400 invalid_cursor. A scope that is neither a domain nor an address is a 422 invalid_knowledge_scope, and a level the key cannot see lists nothing.

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

API
GET /knowledge
TypeScript
knowledge.list()
Python
knowledge.list()
Ruby
knowledge.list
PHP
knowledge->list
Java
knowledge().list
C#
Knowledge.ListAsync
CLI
openemail knowledge list

Knowledge.ListAll

Collect every knowledge item into one slice

محدوده‌های دسترسیknowledge:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
ListAll(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)

Walks every page of List and returns with every item, newest first. One request per page, with the same filters on each.

پارامترها

openemail.WithScopestring

Keeps the items at exactly this level: @ and a domain such as @acme.com, or one address. An empty string is not sent, so ask for the whole-workspace items with level: 'workspace'.

openemail.WithLevelstring

Keeps one kind of level: workspace, domain or address.

openemail.WithKindstring

Keeps one kind of item: note, file or link.

openemail.WithStatus...string

Keeps one status: queued, processing, ready or failed.

openemail.WithPinnedbool

true keeps the pinned notes and false everything else.

openemail.WithQstring

Words in the title, the file name or the link, matched without regard to case or accents.

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

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

خروجی

A []openemail.Object holding every item.

نمونه

failed, err := client.Knowledge.ListAll(ctx, openemail.WithStatus("failed"))if err != nil {	return err} for _, item := range failed {	fmt.Println(item.String("title"), item.String("failure"))}

نکته‌ها

  • If any page fails the call fails and the items already fetched are discarded.

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

API
GET /knowledge
TypeScript
knowledge.listAll()
Python
knowledge.list_all()
Ruby
knowledge.list_all
PHP
knowledge->listAll
Java
knowledge().listAll
C#
Knowledge.ListAllAsync

Knowledge.Iterate

Stream the knowledge items one at a time

محدوده‌های دسترسیknowledge:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
Iterate(ctx context.Context, opts ...openemail.RequestOption) *openemail.Iterator

Returns an iterator that yields one item at a time, newest first, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.

پارامترها

openemail.WithScopestring

Keeps the items at exactly this level: @ and a domain such as @acme.com, or one address. An empty string is not sent, so ask for the whole-workspace items with level: 'workspace'.

openemail.WithLevelstring

Keeps one kind of level: workspace, domain or address.

openemail.WithKindstring

Keeps one kind of item: note, file or link.

openemail.WithStatus...string

Keeps one status: queued, processing, ready or failed.

openemail.WithPinnedbool

true keeps the pinned notes and false everything else.

openemail.WithQstring

Words in the title, the file name or the link, matched without regard to case or accents.

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

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

خروجی

An *openemail.Iterator yielding one item per step.

نمونه

for item, err := range client.Knowledge.Iterate(ctx, openemail.WithPinned(true)).All() {	if err != nil {		return err	} 	fmt.Println(item.String("scope"), item.String("title"))}

نکته‌ها

  • The iterator is lazy, so an abandoned loop costs only the pages you consumed.

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

API
GET /knowledge
TypeScript
knowledge.iterate()
Python
knowledge.iterate()
Ruby
knowledge.iterate
PHP
knowledge->iterate
Java
knowledge().iterate
C#
Knowledge.IterateAsync

Knowledge.Levels

List the levels knowledge can sit at

محدوده‌های دسترسیknowledge:read
امضای متد
Levels(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)

Returns every level the caller can see: the whole workspace first, then each domain, then each address, with how many items each holds and whether the caller may add and change items there. Pass its scope when you add an item.

A key or an app limited to particular addresses sees the whole workspace, its addresses and their domains. writable is true at the whole workspace only for a caller that reaches every address, at a domain for one that holds the whole domain, and at an address for one that holds that address.

پارامترها

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

A []openemail.Object, each with scope, level, writable and items.

نمونه

levels, err := client.Knowledge.Levels(ctx)if err != nil {	return err} for _, level := range levels {	fmt.Println(level.Bool("writable"), level.String("scope"))}

نکته‌ها

  • Needs knowledge:read. A removed address is not a level.

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

API
GET /knowledge/levels
TypeScript
knowledge.levels()
Python
knowledge.levels()
Ruby
knowledge.levels
PHP
knowledge->levels
Java
knowledge().levels
C#
Knowledge.LevelsAsync
CLI
openemail knowledge levels

Knowledge.Usage

Read how much of the plan the knowledge base uses

محدوده‌های دسترسیknowledge:read
امضای متد
Usage(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)

Returns how many items and how many characters of text the workspace keeps in its knowledge base, beside what its plan allows in limits: 50 items and 1,000,000 characters on Free, 500 and 10,000,000 on Starter, 2,000 and 50,000,000 on Business, and 10,000 and 200,000,000 on Enterprise.

An item counts as soon as it is added, and its characters once its text has been read. The numbers are for the whole workspace, whatever the key may reach.

پارامترها

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with plan, sources, chars and limits, which holds sources and chars.

نمونه

usage, err := client.Knowledge.Usage(ctx)if err != nil {	return err} fmt.Println(usage.Int("sources"), usage.Object("limits").Int("sources"), usage.Int("chars"), usage.Object("limits").Int("chars"))

نکته‌ها

  • Needs knowledge:read.

  • Adding an item to a full knowledge base is a 409 knowledge_allowance_reached. A file or a page whose text would pass the allowance once read is kept as failed, with failure: 'over_allowance'.

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

API
GET /knowledge/usage
TypeScript
knowledge.usage()
Python
knowledge.usage()
Ruby
knowledge.usage
PHP
knowledge->usage
Java
knowledge().usage
C#
Knowledge.UsageAsync
CLI
openemail knowledge usage

Knowledge.CreateNote

Add a note to the knowledge base

محدوده‌های دسترسیknowledge:write
امضای متد
CreateNote(ctx context.Context, body openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

Saves a note of up to 20,000 characters at one level and returns with it. Markdown is kept, and its headings become the headings the passages sit under. A note is usually ready for the AI within a second or two, and queued or processing until then.

pinned: true puts the note into every prompt the AI writes at its level, not only when it matches what is being written. The AI reads at most 2,000 characters of pinned notes from each level, so keep them short.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

پارامترها

scopestring

The level: an empty string, or left out, for the whole workspace, @ and a domain such as @acme.com, or one address such as [email protected].

titlestringالزامی

A short name for the note, at most 200 characters.

bodystringالزامی

The text, up to 20,000 characters, in Markdown if you like.

pinnedbool

Puts the note into every prompt at its level. Left out, false.

threadIdstring

The conversation the note comes from, such as the one DraftFromThread read. It is kept on the note as threadId.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object for the new note, with kind: 'note' and origin: 'api'.

نمونه

note, err := client.Knowledge.CreateNote(ctx, openemail.Body{	"scope":  "@acme.com",	"title":  "Refunds",	"body":   "Refunds are paid within 14 days of the return reaching our warehouse.",	"pinned": true,})if err != nil {	return err} fmt.Println(note.String("id"), note.String("status"))

نکته‌ها

  • Needs knowledge:write.

  • A level that is not the workspace, one of its domains or one of its addresses is a 422 invalid_knowledge_scope, and a level outside what the key reaches is a 403 knowledge_scope_not_reached. A full knowledge base is a 409 knowledge_allowance_reached.

  • The SDK does not retry it, because a second attempt after a lost response could save the note twice. Look for it with List before trying again.

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

API
POST /knowledge/notes
TypeScript
knowledge.createNote()
Python
knowledge.create_note()
Ruby
knowledge.create_note
PHP
knowledge->createNote
Java
knowledge().createNote
C#
Knowledge.CreateNoteAsync
CLI
openemail knowledge create-note

Knowledge.UploadFile

Upload a file to the knowledge base

محدوده‌های دسترسیknowledge:write
امضای متد
UploadFile(ctx context.Context, data io.Reader, filename string, opts ...openemail.RequestOption) (openemail.Object, error)

Stores a document or an image at one level and returns with it, queued. Its text is read in the background, and the AI uses it once its status is ready. PDFs, Word documents, spreadsheets (Excel, OpenDocument, Numbers and CSV), OpenDocument text, HTML, XML, Markdown, plain text, JSON and images (JPEG, PNG, WebP and SVG) can be read.

data is an io.Reader, sent as the request body. The name travels as the filename query parameter, and the type is openemail.WithContentType, or the extension of the name when that is left out or generic. A document can be up to 20 MB and an image up to 10 MB.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

پارامترها

dataio.Readerالزامی

The file: an io.Reader, not empty, at most 20 MB for a document and 10 MB for an image.

filenamestringالزامی

The file name, such as price-list.pdf. Its extension tells the kind of file when the type is generic. A missing or blank name is refused before anything is sent.

openemail.WithContentTypestring

The MIME type, such as application/pdf. Left out, the extension of filename decides.

openemail.WithScopestring

The level: an empty string, or left out, for the whole workspace, @ and a domain such as @acme.com, or one address such as [email protected].

openemail.WithTitlestring

A name for the item, at most 200 characters. Left out, the file name without its extension.

openemail.WithTimeouttime.Duration

How long the upload may take. Left out, it is 10 minutes, or the client timeout when that is longer. 0 waits as long as it takes.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object for the new file, with kind: 'file', its fileName, mimeType and sizeBytes, and status: 'queued'.

نمونه

source, err := os.Open("handbook.pdf")if err != nil {	return err} defer source.Close() file, err := client.Knowledge.UploadFile(	ctx,	source,	"price-list.pdf",	openemail.WithContentType("application/pdf"),	openemail.WithScope("[email protected]"),)if err != nil {	return err} fmt.Println(file.String("id"), file.String("title"), file.String("status"))

نکته‌ها

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

API
POST /knowledge/files
TypeScript
knowledge.uploadFile()
Python
knowledge.upload_file()
Ruby
knowledge.upload_file
PHP
knowledge->uploadFile
Java
knowledge().uploadFile
C#
Knowledge.UploadFileAsync
CLI
openemail knowledge upload-file

Knowledge.Get

Read one knowledge item and its text

محدوده‌های دسترسیknowledge:read
امضای متد
Get(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Returns one item with its text: the body of a note, or in preview the first 20,000 characters read from a file or a page, with previewTruncated true when the text goes on past it. preview is null while a file or a page has not been read yet, and body is null for anything but a note.

پارامترها

idstringالزامی

The id of the item, kb_ and 24 hex characters, as List returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object, the fields List returns plus body, preview and previewTruncated.

نمونه

item, err := client.Knowledge.Get(ctx, "kb_8c1f4a2b9d7e3f60a5c7b21d")if err != nil {	return err} fmt.Println(item.String("title"), item.String("body"), item.String("preview"))

نکته‌ها

  • Needs knowledge:read. An unknown id, and an item at a level the key cannot see, answer 404 knowledge_not_found.

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

API
GET /knowledge/{id}
TypeScript
knowledge.get()
Python
knowledge.get()
Ruby
knowledge.get
PHP
knowledge->get
Java
knowledge().get
C#
Knowledge.GetAsync
CLI
openemail knowledge get

Knowledge.Update

Change a knowledge item

محدوده‌های دسترسیknowledge:write
امضای متد
Update(ctx context.Context, id string, patch openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

Changes the title of an item, the text of a note, the page of a link, how often a link is read again, whether a note is pinned, or its level, and returns with the item as it is now. Give at least one field. A changed title, text or link is read and indexed again, so the item goes back to queued, and its previous text stays in use until the new one is ready. Moving an item to another level needs no new reading.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole. Moving an item needs that reach at both levels.

پارامترها

idstringالزامی

The id of the item, kb_ and 24 hex characters, as List returns it.

titlestring

A new name, at most 200 characters.

bodystring

The new text of a note, up to 20,000 characters.

scopestring

The level to move it to: an empty string for the whole workspace, @ and a domain, or one address.

pinnedbool

Whether a note goes into every prompt at its level.

urlstring

The new page of a link, a public http or https address.

refreshDaysint | nil

Reads a link again every 1, 7 or 30 days, counted from now. null stops that.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object as it is now.

نمونه

item, err := client.Knowledge.Update(ctx, "kb_8c1f4a2b9d7e3f60a5c7b21d", openemail.Body{	"body":   "Refunds are paid within 10 days of the return reaching our warehouse.",	"pinned": true,})if err != nil {	return err} fmt.Println(item.String("status"), item.String("updatedAt"))

نکته‌ها

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

API
PATCH /knowledge/{id}
TypeScript
knowledge.update()
Python
knowledge.update()
Ruby
knowledge.update
PHP
knowledge->update
Java
knowledge().update
C#
Knowledge.UpdateAsync
CLI
openemail knowledge update

Knowledge.Delete

Delete a knowledge item for good

محدوده‌های دسترسیknowledge:write
امضای متد
Delete(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Removes an item with its file and every passage read from it, and the AI stops using it at once. There is no undo.

پارامترها

idstringالزامی

The id of the item, kb_ and 24 hex characters, as List returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with object set to knowledge_item, id and deleted set to true.

نمونه

removed, err := client.Knowledge.Delete(ctx, "kb_8c1f4a2b9d7e3f60a5c7b21d")if err != nil {	return err} fmt.Println(removed.Bool("deleted"))

نکته‌ها

  • Needs knowledge:write, and reach over the level of the item. An unknown id is a 404 knowledge_not_found.

  • The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.

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

API
DELETE /knowledge/{id}
TypeScript
knowledge.delete()
Python
knowledge.delete()
Ruby
knowledge.delete
PHP
knowledge->delete
Java
knowledge().delete
C#
Knowledge.DeleteAsync
CLI
openemail knowledge delete

Knowledge.Refresh

Read a knowledge item again

محدوده‌های دسترسیknowledge:write
امضای متد
Refresh(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Fetches a link again, reads a file again or indexes a note again, clears any failure and returns with the item, back at queued. Use it after a page changed or when an item failed. The previous text stays in use until the new one is ready.

پارامترها

idstringالزامی

The id of the item, kb_ and 24 hex characters, as List returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object, queued to be read again.

نمونه

item, err := client.Knowledge.Refresh(ctx, "kb_8c1f4a2b9d7e3f60a5c7b21d")if err != nil {	return err} fmt.Println(item.String("id"), item.String("status"))

نکته‌ها

  • Needs knowledge:write, and reach over the level of the item.

  • Reading an item again twice leaves it the same way, so the SDK retries it on network failure and retryable statuses.

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

API
POST /knowledge/{id}/refresh
TypeScript
knowledge.refresh()
Python
knowledge.refresh()
Ruby
knowledge.refresh
PHP
knowledge->refresh
Java
knowledge().refresh
C#
Knowledge.RefreshAsync
CLI
openemail knowledge refresh

Knowledge.Stats

Read how the AI used the knowledge base

محدوده‌های دسترسیknowledge:read
امضای متد
Stats(ctx context.Context, opts ...openemail.RequestOption) (openemail.Object, error)

Returns how the AI used the knowledge base over the last days days, today included, 30 unless you say. uses counts the times a reply suggestion, a draft, the assistant or a search found something in it, and empty the times it looked and found nothing. coverage is uses divided by the two together, from 0 to 1, and 0 when it never looked. bySurface splits uses by where they happened, under the keys compose, reply, chat, tool and Search, and series has one entry per day, oldest first, days with nothing included.

topItems lists the items used most, ever, and unusedItems counts the ready items the AI has never used. pendingSuggestions counts the learned notes waiting for review, openQuestions the questions senders asked that nothing answers yet, and openFlags the open duplicate and conflict flags. uses, empty, bySurface and series cover the whole workspace, while the items, suggestions, questions and flags count only what the caller can see.

پارامترها

openemail.WithDaysint

How many days back to count, today included, from 1 to 90. The server defaults to 30.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with days, uses, empty, coverage, bySurface, series, topItems, unusedItems, pendingSuggestions, openQuestions and openFlags. Each day in series is a map with day, uses and empty, and each of topItems is a map with id, title, kind, scope, uses and lastUsedAt.

نمونه

stats, err := client.Knowledge.Stats(ctx, openemail.WithDays(7))if err != nil {	return err} fmt.Println(stats.Int("coverage"))

نکته‌ها

  • Needs knowledge:read. It changes nothing, so the SDK retries it like any other read.

  • A days outside 1 to 90 is a 422 invalid_parameter.

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

API
GET /knowledge/stats
TypeScript
knowledge.stats()
Python
knowledge.stats()
Ruby
knowledge.stats
PHP
knowledge->stats
Java
knowledge().stats
C#
Knowledge.StatsAsync
CLI
openemail knowledge stats

Knowledge.ListSuggestions

List one page of knowledge suggestions and questions

محدوده‌های دسترسیknowledge:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
ListSuggestions(ctx context.Context, opts ...openemail.RequestOption) (*openemail.Page, error)

Returns one page of what the AI suggests adding to the knowledge base, the most recent first, pending ones unless you ask for another status. ListAllSuggestions collects every page and IterateSuggestions walks them lazily.

A learned suggestion is a note the AI drew from a reply sent from the workspace: it reads the message the reply answers and the reply, and keeps up to three facts that would hold for other people too, at the level of the domain the reply was sent from, or the whole workspace when that domain is not one of its own. Facts the knowledge base already holds are left out, and at most 100 replies a day are read. A question is something a sender asked about the business that neither the conversation nor the knowledge base answers: when the AI suggests replies to an incoming message, it notes up to 3 such questions, at the level of the domain the message arrived at, chosen the same way. Accept a question with its answer and it becomes a note.

The same fact or question again counts up occurrences instead of adding a second suggestion, and one that was dismissed is not suggested again. Both kinds stop while the workspace setting knowledgeLearning is off, which Settings.Update changes.

پارامترها

openemail.WithKindstring

Keeps one kind: learned for notes drawn from sent replies, or question for questions nothing answers.

openemail.WithStatus...string

Keeps one status: pending, accepted or dismissed. Left out, pending.

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

A *openemail.Page with Items, HasMore and NextCursor. Each suggestion has id, kind, status, scope, level, title, body, occurrences, threadId, sourceId, createdAt, updatedAt and decidedAt.

نمونه

page, err := client.Knowledge.ListSuggestions(ctx, openemail.WithKind("question"))if err != nil {	return err} for _, suggestion := range page.Items {	fmt.Println(suggestion.Int("occurrences"), suggestion.String("title"))} fmt.Println(page.HasMore, page.NextCursor)

نکته‌ها

  • Needs knowledge:read, which knowledge:write includes.

  • A learned suggestion holds the suggested note in title and body. A question holds the question in title, and its body is null until it is answered. threadId names the conversation it came from most recently, and sourceId the note made from it once it is accepted.

  • A key or an app limited to particular addresses sees the suggestions at the whole workspace, at its addresses and at their domains. The cursor is opaque, and one this list did not hand out is a 400 invalid_cursor.

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

API
GET /knowledge/suggestions
TypeScript
knowledge.listSuggestions()
Python
knowledge.list_suggestions()
Ruby
knowledge.list_suggestions
PHP
knowledge->listSuggestions
Java
knowledge().listSuggestions
C#
Knowledge.ListSuggestionsAsync
CLI
openemail knowledge list-suggestions

Knowledge.ListAllSuggestions

Collect every knowledge suggestion into one slice

محدوده‌های دسترسیknowledge:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
ListAllSuggestions(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)

Walks every page of ListSuggestions and returns with every suggestion or question that matches, the most recent first. One request per page, with the same filters on each.

پارامترها

openemail.WithKindstring

Keeps one kind: learned for notes drawn from sent replies, or question for questions nothing answers.

openemail.WithStatus...string

Keeps one status: pending, accepted or dismissed. Left out, pending.

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

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

خروجی

A []openemail.Object holding every suggestion and question that matches.

نمونه

questions, err := client.Knowledge.ListAllSuggestions(ctx, openemail.WithKind("question"))if err != nil {	return err} for _, suggestion := range questions {	fmt.Println(suggestion.String("id"), suggestion.String("status"))}

نکته‌ها

  • If any page fails the call fails and the suggestions already fetched are discarded.

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

API
GET /knowledge/suggestions
TypeScript
knowledge.listAllSuggestions()
Python
knowledge.list_all_suggestions()
Ruby
knowledge.list_all_suggestions
PHP
knowledge->listAllSuggestions
Java
knowledge().listAllSuggestions
C#
Knowledge.ListAllSuggestionsAsync

Knowledge.IterateSuggestions

Stream the knowledge suggestions one at a time

محدوده‌های دسترسیknowledge:readنتایج را صفحه‌به‌صفحه مرور می‌کند
امضای متد
IterateSuggestions(ctx context.Context, opts ...openemail.RequestOption) *openemail.Iterator

Returns an iterator that yields one suggestion or question at a time, the most recent first, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.

پارامترها

openemail.WithKindstring

Keeps one kind: learned for notes drawn from sent replies, or question for questions nothing answers.

openemail.WithStatus...string

Keeps one status: pending, accepted or dismissed. Left out, pending.

openemail.WithLimitint

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

openemail.WithCursorstring

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

openemail.WithAPIKeystring

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

خروجی

An *openemail.Iterator yielding one suggestion or question per step.

نمونه

for suggestion, err := range client.Knowledge.IterateSuggestions(ctx, openemail.WithKind("learned")).All() {	if err != nil {		return err	} 	fmt.Println(suggestion.String("scope"), suggestion.String("title"))}

نکته‌ها

  • The iterator is lazy, so an abandoned loop costs only the pages you consumed.

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

API
GET /knowledge/suggestions
TypeScript
knowledge.iterateSuggestions()
Python
knowledge.iterate_suggestions()
Ruby
knowledge.iterate_suggestions
PHP
knowledge->iterateSuggestions
Java
knowledge().iterateSuggestions
C#
Knowledge.IterateSuggestionsAsync

Knowledge.AcceptSuggestion

Save a knowledge suggestion as a note

محدوده‌های دسترسیknowledge:write
امضای متد
AcceptSuggestion(ctx context.Context, id string, body openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

Saves a pending suggestion or question as a note, marks it accepted and returns with both: the suggestion, its sourceId naming the new note, and the note itself in item. Any field you send takes the place of the suggested one, so you can tidy the title, rewrite the text, move it to another level or pin it on the way in. The note keeps the conversation the suggestion came from in threadId.

A question needs its answer in body, and its title stays the question unless you send one. Answering a question this way is how it becomes a note the AI uses from then on.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

پارامترها

idstringالزامی

The id of the suggestion or question, kp_ and 24 hex characters, as ListSuggestions returns it.

titlestring

A title for the note, at most 200 characters. Left out, the suggested title or the question.

bodystring

The text of the note, up to 20,000 characters. Left out, the suggested note. A question needs it: the answer.

scopestring

The level for the note: an empty string for the whole workspace, @ and a domain, or one address. Left out, the suggested level.

pinnedbool

Puts the note into every prompt at its level. Left out, false.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with object set to knowledge_suggestion_accepted, suggestion and item, with the suggestion accepted and the new note as a knowledge item object.

نمونه

accepted, err := client.Knowledge.AcceptSuggestion(ctx, "kp_3f9a1c7e5b2d8046a1c3e5f7", openemail.Body{"body": "Orders over 50 euros ship free within the EU."})if err != nil {	return err} fmt.Println(accepted.String("object"))

نکته‌ها

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

API
POST /knowledge/suggestions/{id}/accept
TypeScript
knowledge.acceptSuggestion()
Python
knowledge.accept_suggestion()
Ruby
knowledge.accept_suggestion
PHP
knowledge->acceptSuggestion
Java
knowledge().acceptSuggestion
C#
Knowledge.AcceptSuggestionAsync
CLI
openemail knowledge accept-suggestion

Knowledge.DismissSuggestion

Dismiss a knowledge suggestion or question

محدوده‌های دسترسیknowledge:write
امضای متد
DismissSuggestion(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Marks a pending suggestion or question dismissed and returns with it. It leaves the pending list, the same fact or question is not suggested again, and nothing is added to the knowledge base.

Dismissing needs the reach to add a note at the level of the suggestion: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address.

پارامترها

idstringالزامی

The id of the suggestion or question, kp_ and 24 hex characters, as ListSuggestions returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with status: 'dismissed' and decidedAt set.

نمونه

dismissed, err := client.Knowledge.DismissSuggestion(ctx, "kp_3f9a1c7e5b2d8046a1c3e5f7")if err != nil {	return err} fmt.Println(dismissed.String("status"), dismissed.String("decidedAt"))

نکته‌ها

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

API
POST /knowledge/suggestions/{id}/dismiss
TypeScript
knowledge.dismissSuggestion()
Python
knowledge.dismiss_suggestion()
Ruby
knowledge.dismiss_suggestion
PHP
knowledge->dismissSuggestion
Java
knowledge().dismissSuggestion
C#
Knowledge.DismissSuggestionAsync
CLI
openemail knowledge dismiss-suggestion

Knowledge.ListFlags

List the open duplicate and conflict flags

محدوده‌های دسترسیknowledge:read
امضای متد
ListFlags(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)

Returns the open warnings about pairs of knowledge items, newest first. Each item is compared with the closest items at every level when it is indexed, and again whenever it changes. duplicate means the two items say nearly the same thing. conflict means the AI found that two closely related items disagree on a fact, such as a price or a deadline, and detail says how in one sentence. The AI looks for conflicts while the workspace setting knowledgeLearning is on, at most 200 times a day.

Change or delete one of the two items to settle a flag: a changed item is compared again once it is indexed, and the flags of a deleted item go with it. When the two are fine as they are, dismiss the flag with DismissFlag. A flag shows only to a caller who can see both items.

پارامترها

openemail.WithItemIDstring

Keeps the flags that name this knowledge item, on either side.

openemail.WithLimitint

How many flags, from 1 to 100. The server defaults to 50.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

A []openemail.Object, each with id, kind, status, sourceId, sourceTitle, otherSourceId, otherSourceTitle, detail, score and createdAt. score is how close in meaning the two items are, from 0 to 1.

نمونه

flags, err := client.Knowledge.ListFlags(ctx)if err != nil {	return err} for _, flag := range flags {	fmt.Println(flag.String("kind"), flag.String("sourceTitle"), flag.String("otherSourceTitle"), flag.String("detail"))}

نکته‌ها

  • Needs knowledge:read. Every item also carries flags, the number of open flags that name it, so List shows which items to look at.

  • Only open flags are listed. A dismissed flag stays dismissed, and the same two items are not flagged for the same reason again.

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

API
GET /knowledge/flags
TypeScript
knowledge.listFlags()
Python
knowledge.list_flags()
Ruby
knowledge.list_flags
PHP
knowledge->listFlags
Java
knowledge().listFlags
C#
Knowledge.ListFlagsAsync
CLI
openemail knowledge list-flags

Knowledge.DismissFlag

Dismiss a duplicate or conflict flag

محدوده‌های دسترسیknowledge:write
امضای متد
DismissFlag(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Marks a flag dismissed when the two items are fine as they are, and returns with it. The same two items are not flagged for the same reason again. To settle a real duplicate or conflict instead, change or delete one of the items.

Dismissing needs the reach to change items at the levels of both items: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address.

پارامترها

idstringالزامی

The id of the flag, kf_ and 24 hex characters, as ListFlags returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with status: 'dismissed'.

نمونه

flag, err := client.Knowledge.DismissFlag(ctx, "kb_8c1f4a2b9d7e3f60a5c7b21d")if err != nil {	return err} fmt.Println(flag.String("id"), flag.String("status"))

نکته‌ها

  • Needs knowledge:write. An unknown id, and a flag on an item the key cannot see, answer 404 knowledge_flag_not_found, and an item the key may not change is a 403 knowledge_scope_not_reached.

  • Dismissing a flag twice leaves it the same way, so the SDK retries it on network failure and retryable statuses.

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

API
POST /knowledge/flags/{id}/dismiss
TypeScript
knowledge.dismissFlag()
Python
knowledge.dismiss_flag()
Ruby
knowledge.dismiss_flag
PHP
knowledge->dismissFlag
Java
knowledge().dismissFlag
C#
Knowledge.DismissFlagAsync
CLI
openemail knowledge dismiss-flag

Knowledge.ListConnectors

List the knowledge connectors

محدوده‌های دسترسیknowledge:read
امضای متد
ListConnectors(ctx context.Context, opts ...openemail.RequestOption) ([]openemail.Object, error)

Returns every connector at a level the caller can see, newest first. A connector keeps many web pages from one source in the knowledge base, each page as a link item at the connector's level: a site it crawls, a sitemap, an RSS or Atom feed, or a Zendesk help center. Each one says how many items it keeps, its status, when it last synced and when it syncs next.

پارامترها

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

A []openemail.Object, each with id, kind, scope, level, title, url, refreshDays, pageLimit, status, failure, items, lastSyncAt, nextSyncAt, createdAt and updatedAt.

نمونه

connectors, err := client.Knowledge.ListConnectors(ctx)if err != nil {	return err} for _, connector := range connectors {	fmt.Println(connector.String("kind"), connector.String("url"), connector.Int("items"), connector.String("status"))}

نکته‌ها

  • Needs knowledge:read. A key or an app limited to particular addresses sees the connectors at the whole workspace, at its addresses and at their domains.

  • The items a connector keeps show in List too, each with connectorId naming it.

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

API
GET /knowledge/connectors
TypeScript
knowledge.listConnectors()
Python
knowledge.list_connectors()
Ruby
knowledge.list_connectors
PHP
knowledge->listConnectors
Java
knowledge().listConnectors
C#
Knowledge.ListConnectorsAsync
CLI
openemail knowledge list-connectors

Knowledge.AddConnector

Keep the pages of a site, sitemap, feed or help center

محدوده‌های دسترسیknowledge:write
امضای متد
AddConnector(ctx context.Context, body openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

Adds a connector at one level and returns with it, queued. Its first sync starts within a minute, and every page it finds becomes a link item at the connector's level, read in the background like any other link.

site reads the page at url and follows its links to pages on the same host under the same path, leaving out what the site's robots.txt disallows. sitemap reads a sitemap, or a sitemap index and up to 5 of its sitemaps. feed reads an RSS or Atom feed. zendesk reads the published articles of a Zendesk help center from its address, such as https://example.zendesk.com.

It keeps at most pageLimit pages, 25 unless you say, and syncs again every refreshDays days, 7 unless you say: new pages are added, changed ones are read again and the items of pages that are gone are removed. A page already in the knowledge base as a link at the same level is left to that item. Its items count toward the plan allowance, and a sync stops adding pages once that is reached.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole.

پارامترها

kindstringالزامی

What url is: site, sitemap, feed or zendesk.

urlstringالزامی

A public web address of at most 2,048 characters, kept as https: the page a site crawl starts from, the sitemap, the feed, or the address of the help center.

scopestring

The level: an empty string, or left out, for the whole workspace, @ and a domain such as @acme.com, or one address such as [email protected].

titlestring

A name for the connector, at most 200 characters. Left out, the host and the kind, such as acme.com (sitemap).

refreshDaysint | nil

Sync again every 1, 7 or 30 days. Left out, 7. null syncs only when you call SyncConnector.

pageLimitint

The most pages to keep, from 1 to 200. Left out, 25.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object for the new connector, with status: 'queued' and items: 0.

نمونه

docs, err := client.Knowledge.AddConnector(ctx, openemail.Body{	"kind":      "sitemap",	"url":       "https://acme.com/sitemap.xml",	"scope":     "@acme.com",	"pageLimit": 100,})if err != nil {	return err} fmt.Println(docs.String("id"), docs.String("status"))

نکته‌ها

  • Needs knowledge:write.

  • An address that is not a public web address is a 422 invalid_knowledge_connector, and the same address at the same level a 409 knowledge_connector_exists. A refreshDays other than 1, 7, 30 or null is a 422 invalid_knowledge_refresh. A level that is not the workspace, one of its domains or one of its addresses is a 422 invalid_knowledge_scope, and a level outside what the key reaches is a 403 knowledge_scope_not_reached.

  • A source that cannot be read after several tries ends failed with a failure. A sync that stopped at the plan allowance ends ready with failure: 'over_allowance', and one that found nothing ends ready with failure: 'empty'.

  • The SDK does not retry it. A second attempt after a lost response answers 409 knowledge_connector_exists, which means the first one worked.

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

API
POST /knowledge/connectors
TypeScript
knowledge.addConnector()
Python
knowledge.add_connector()
Ruby
knowledge.add_connector
PHP
knowledge->addConnector
Java
knowledge().addConnector
C#
Knowledge.AddConnectorAsync
CLI
openemail knowledge add-connector

Knowledge.GetConnector

Read one knowledge connector

محدوده‌های دسترسیknowledge:read
امضای متد
GetConnector(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Returns one connector: its source, its level, how many items it keeps, its status, and when it last synced and syncs next. status is queued until a sync starts, syncing while it reads the source, ready once its pages are items, and failed with a failure when the source could not be read after several tries.

پارامترها

idstringالزامی

The id of the connector, kc_ and 24 hex characters, as ListConnectors returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object, the fields ListConnectors returns for each connector.

نمونه

connector, err := client.Knowledge.GetConnector(ctx, "kc_5d2e8f1a3c7b9064e2a4c6f8")if err != nil {	return err} fmt.Println(connector.String("status"), connector.Int("items"), connector.String("nextSyncAt"))

نکته‌ها

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

API
GET /knowledge/connectors/{id}
TypeScript
knowledge.getConnector()
Python
knowledge.get_connector()
Ruby
knowledge.get_connector
PHP
knowledge->getConnector
Java
knowledge().getConnector
C#
Knowledge.GetConnectorAsync
CLI
openemail knowledge get-connector

Knowledge.UpdateConnector

Change a knowledge connector

محدوده‌های دسترسیknowledge:write
امضای متد
UpdateConnector(ctx context.Context, id string, patch openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

Changes the title of a connector, its level, how often it syncs or the most pages it keeps, and returns with it as it is now. Give at least one field. Moving it to another level moves its items with it, and they are indexed again there. A new refreshDays counts from the last sync, and a new pageLimit applies from the next sync.

Changing an item needs reach over every address its level covers: the whole workspace needs every address, a domain needs the whole domain, and an address needs that address. A key or an app limited to particular addresses can change items only at those addresses, or at domains it holds whole. Moving a connector needs that reach at both levels.

پارامترها

idstringالزامی

The id of the connector, kc_ and 24 hex characters, as ListConnectors returns it.

titlestring

A new name, at most 200 characters.

scopestring

The level to move it and its items to: an empty string for the whole workspace, @ and a domain, or one address.

refreshDaysint | nil

Sync every 1, 7 or 30 days. null syncs only when you call SyncConnector.

pageLimitint

The most pages to keep, from 1 to 200.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object as it is now.

نمونه

connector, err := client.Knowledge.UpdateConnector(ctx, "kc_5d2e8f1a3c7b9064e2a4c6f8", openemail.Body{"refreshDays": 1, "pageLimit": 150})if err != nil {	return err} fmt.Println(connector.String("nextSyncAt"))

نکته‌ها

  • Needs knowledge:write. An empty patch is a 422 invalid_parameter, and a refreshDays other than 1, 7, 30 or null a 422 invalid_knowledge_refresh. Moving it to a level that already has a connector for the same address is a 409 knowledge_connector_exists.

  • Retried automatically on network failure and retryable statuses, since the same patch applied twice leaves the same connector.

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

API
PATCH /knowledge/connectors/{id}
TypeScript
knowledge.updateConnector()
Python
knowledge.update_connector()
Ruby
knowledge.update_connector
PHP
knowledge->updateConnector
Java
knowledge().updateConnector
C#
Knowledge.UpdateConnectorAsync
CLI
openemail knowledge update-connector

Knowledge.DeleteConnector

Delete a knowledge connector and its items

محدوده‌های دسترسیknowledge:write
امضای متد
DeleteConnector(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Removes a connector with every item it added to the knowledge base, and the AI stops using them at once. There is no undo. Links you added yourself stay, even when the connector found the same pages.

پارامترها

idstringالزامی

The id of the connector, kc_ and 24 hex characters, as ListConnectors returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with object set to knowledge_connector, id and deleted set to true.

نمونه

removed, err := client.Knowledge.DeleteConnector(ctx, "kc_5d2e8f1a3c7b9064e2a4c6f8")if err != nil {	return err} fmt.Println(removed.Bool("deleted"))

نکته‌ها

  • Needs knowledge:write, and reach over the level of the connector. An unknown id is a 404 knowledge_connector_not_found.

  • The SDK does not retry a delete. A 404 on your own second attempt after a lost response means the first one worked.

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

API
DELETE /knowledge/connectors/{id}
TypeScript
knowledge.deleteConnector()
Python
knowledge.delete_connector()
Ruby
knowledge.delete_connector
PHP
knowledge->deleteConnector
Java
knowledge().deleteConnector
C#
Knowledge.DeleteConnectorAsync
CLI
openemail knowledge delete-connector

Knowledge.SyncConnector

Sync a knowledge connector now

محدوده‌های دسترسیknowledge:write
امضای متد
SyncConnector(ctx context.Context, id string, opts ...openemail.RequestOption) (openemail.Object, error)

Queues a sync that starts within a minute, whatever the schedule says, clears any failure and returns with the connector, back at queued. Use it after the source changed, or to try again after a failure. Like a scheduled sync, it adds new pages, reads changed ones again and removes the items of pages that are gone.

پارامترها

idstringالزامی

The id of the connector, kc_ and 24 hex characters, as ListConnectors returns it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object, queued to sync.

نمونه

connector, err := client.Knowledge.SyncConnector(ctx, "kb_8c1f4a2b9d7e3f60a5c7b21d")if err != nil {	return err} fmt.Println(connector.String("id"), connector.String("status"))

نکته‌ها

  • Needs knowledge:write, and reach over the level of the connector. An unknown id is a 404 knowledge_connector_not_found.

  • Queuing a sync twice leaves it the same way, so the SDK retries it on network failure and retryable statuses.

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

API
POST /knowledge/connectors/{id}/sync
TypeScript
knowledge.syncConnector()
Python
knowledge.sync_connector()
Ruby
knowledge.sync_connector
PHP
knowledge->syncConnector
Java
knowledge().syncConnector
C#
Knowledge.SyncConnectorAsync
CLI
openemail knowledge sync-connector

Knowledge.DraftFromThread

Draft a knowledge note from a conversation

محدوده‌های دسترسیknowledge:writethreads:read
امضای متد
DraftFromThread(ctx context.Context, body openemail.Body, opts ...openemail.RequestOption) (openemail.Object, error)

The AI reads a conversation and drafts one note of the facts in it that the team will need again, leaving out personal details and what matters only to that conversation. Nothing is saved: the draft comes back with a title, a body in Markdown and a scope it suggests, and you keep it, changed as you like, with CreateNote and the same threadId.

scope suggests the domain the conversation arrived at when the caller may add items there, otherwise the whole workspace or the address itself. Each draft counts as one AI action.

پارامترها

threadIdstringالزامی

The conversation, by the id Threads.List gives it.

openemail.WithAPIKeystring

Overrides the client API key for this call only.

خروجی

An openemail.Object with object set to knowledge_draft, title, body, scope and threadId.

نمونه

draft, err := client.Knowledge.DraftFromThread(ctx, openemail.Body{"threadId": "CAHk7pQ2x9LmZ4-mail.example.com"})if err != nil {	return err} fmt.Println(draft.String("scope"), draft.String("title"), draft.String("body"), draft.String("threadId"))

نکته‌ها

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

API
POST /knowledge/drafts
TypeScript
knowledge.draftFromThread()
Python
knowledge.draft_from_thread()
Ruby
knowledge.draft_from_thread
PHP
knowledge->draftFromThread
Java
knowledge().draftFromThread
C#
Knowledge.DraftFromThreadAsync
CLI
openemail knowledge draft-from-thread