// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as ChatbotsAPI from '../../chatbots'; import * as ModelsAPI from './models'; import { ChatbotModelItem, ModelListParams, ModelListResponse, Models } from './models'; import { APIPromise } from '../../../core/api-promise'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class Chatbots extends APIResource { models: ModelsAPI.Models = new ModelsAPI.Models(this._client); /** * Retrieve detail for a single chatbot by its slug. */ retrieve( chatbotSlug: string, params: ChatbotRetrieveParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get(path`/v2/chatbots/${chatbotSlug}`, { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Retrieve a paginated list of chatbots available for the specified user. Models * are omitted; use `GET /v2/chatbots/{chatbot_id}/models` to load them on demand. * Uses cursor-based pagination. */ list( params: ChatbotListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'If-None-Match': ifNoneMatch, 'X-Error-Format': xErrorFormat, ...query } = params ?? {}; return this._client.get('/v2/chatbots', { query, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(ifNoneMatch != null ? { 'If-None-Match': ifNoneMatch } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * The Digital Employee a project is locked to in focus mode, as shown in the * chatbot response. * * Built best-effort: when the profile can't be fetched from GL Runner, only `id` * is set and `is_available` is False, so a GL Runner outage never fails the * chatbot response. * * Attributes: id (str): GLChat's local Digital Employee id (the * `digital_employee_id` `/message` takes). name (str | None): Display name, or * None when the profile couldn't be fetched. role_title (str | None): * Human-readable role/title. avatar_url (str | None): Avatar image URL. * description (str): Short "who this DE is" blurb. is_available (bool): True only * when GL Runner reports the Digital Employee as active. False when it is * inactive, no longer exists, or the lookup failed. is_pinned (bool): Whether the * calling user has pinned this Digital Employee in the project it is listed under. * Always False for guests and wherever no project/user context applies. */ export interface DefaultDigitalEmployee { id: string; avatar_url?: string | null; description?: string; is_available?: boolean; is_pinned?: boolean; name?: string | null; role_title?: string | null; } /** * Response model for paginated user chatbots (`GET /v2/chatbots`). * * Attributes: chatbots (list[ChatbotItemV2]): Page of chatbots available to the * user (without embedded models). cursor (str | None): Opaque cursor for the next * page, URL-encoded as `{ISO_8601_timestamp}|{chatbot_id}`. Pass as-is to the next * request; absent on the last page. chatbots_count (int): Total count of * accessible chatbots before pagination. default_chatbot (ChatbotItemV2 | None): * Organization's default chatbot. If set and accessible, this chatbot will be * placed first in the chatbots list. None if no default is set or if the default * chatbot is not accessible to the user. */ export interface ChatbotListResponse { chatbots: Array; chatbots_count: number; cursor?: string | null; /** * Chatbot payload for `GET /v2/chatbots` (models are fetched on demand via * dedicated endpoints). */ default_chatbot?: ChatbotsAPI.ChatbotItemV2 | null; } export interface ChatbotRetrieveParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export interface ChatbotListParams { /** * Query param: Pointer to keep track of the last fetched chatbots */ cursor?: string | null; /** * Query param: Number of chatbots to return per request */ limit?: number; /** * Query param: The phone number of the provider */ phone_number?: string | null; /** * Query param: Filter chatbots by name, description, or public ID * (case-insensitive substring match) */ query?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param */ 'If-None-Match'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } Chatbots.Models = Models; export declare namespace Chatbots { export { type DefaultDigitalEmployee as DefaultDigitalEmployee, type ChatbotListResponse as ChatbotListResponse, type ChatbotRetrieveParams as ChatbotRetrieveParams, type ChatbotListParams as ChatbotListParams, }; export { Models as Models, type ChatbotModelItem as ChatbotModelItem, type ModelListResponse as ModelListResponse, type ModelListParams as ModelListParams, }; }