conversations
Manage customer interactions by retrieving, updating, and sending messages in conversations. Assign agents, monitor status, and streamline communication workflows using Brevo MCP Server.
Instructions
Chat and conversation management - handle customer conversations
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| agentId | No | Agent ID for conversation assignment | |
| conversationId | No | Conversation ID | |
| message | No | Message content to send | |
| operation | Yes | Conversation operation to perform | |
| status | No | Conversation status |
Implementation Reference
- node_modules/@getbrevo/brevo/api/apis.ts:66-66 (registration)ConversationsApi is included in the central APIS array that is used to dynamically register all Brevo API clients as MCP tools. The tool name 'conversations' maps to this API class.export const APIS = [AccountApi, CompaniesApi, ContactsApi, ConversationsApi, CouponsApi, DealsApi, DomainsApi, EcommerceApi, EmailCampaignsApi, EventsApi, ExternalFeedsApi, FilesApi, InboundParsingApi, MasterAccountApi, NotesApi, PaymentsApi, ProcessApi, ResellerApi, SMSCampaignsApi, SendersApi, TasksApi, TransactionalEmailsApi, TransactionalSMSApi, TransactionalWhatsAppApi, UserApi, WebhooksApi, WhatsAppCampaignsApi];
- The ConversationsApi class provides the complete handler logic for all 'conversations' tool operations, with methods corresponding to different Brevo API endpoints for managing conversations, messages, and agent status.export class ConversationsApi { protected _basePath = defaultBasePath; protected _defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': <Authentication>new VoidAuth(), 'apiKey': new ApiKeyAuth('header', 'api-key'), 'partnerKey': new ApiKeyAuth('header', 'partner-key'), } protected interceptors: Interceptor[] = []; constructor(basePath?: string); constructor(basePathOrUsername: string, password?: string, basePath?: string) { if (password) { if (basePath) { this.basePath = basePath; } } else { if (basePathOrUsername) { this.basePath = basePathOrUsername } } } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } set defaultHeaders(defaultHeaders: any) { this._defaultHeaders = defaultHeaders; } get defaultHeaders() { return this._defaultHeaders; } get basePath() { return this._basePath; } public setDefaultAuthentication(auth: Authentication) { this.authentications.default = auth; } public setApiKey(key: ConversationsApiApiKeys, value: string) { (this.authentications as any)[ConversationsApiApiKeys[key]].apiKey = value; } public addInterceptor(interceptor: Interceptor) { this.interceptors.push(interceptor); } /** * We recommend pinging this endpoint every minute for as long as the agent has to be considered online. * @summary Sets agent’s status to online for 2-3 minutes * @param body Agent fields. */ public async conversationsAgentOnlinePingPost (body: ConversationsAgentOnlinePingPostRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/conversations/agentOnlinePing'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling conversationsAgentOnlinePingPost.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(body, "ConversationsAgentOnlinePingPostRequest") }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Only agents’ messages can be deleted. * @summary Delete a message sent by an agent * @param id ID of the message */ public async conversationsMessagesIdDelete (id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/conversations/messages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling conversationsMessagesIdDelete.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'DELETE', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Get a message * @param id ID of the message */ public async conversationsMessagesIdGet (id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }> { const localVarPath = this.basePath + '/conversations/messages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling conversationsMessagesIdGet.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "ConversationsMessage"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Only agents’ messages can be edited. * @summary Update a message sent by an agent * @param id ID of the message * @param body */ public async conversationsMessagesIdPut (id: string, body?: ConversationsMessagesIdPutRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }> { const localVarPath = this.basePath + '/conversations/messages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling conversationsMessagesIdPut.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(body, "ConversationsMessagesIdPutRequest") }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "ConversationsMessage"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Send a message as an agent * @param body Message fields. */ public async conversationsMessagesPost (body: ConversationsMessagesPostRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }> { const localVarPath = this.basePath + '/conversations/messages'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling conversationsMessagesPost.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(body, "ConversationsMessagesPostRequest") }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "ConversationsMessage"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Delete an automated message * @param id ID of the message */ public async conversationsPushedMessagesIdDelete (id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body?: any; }> { const localVarPath = this.basePath + '/conversations/pushedMessages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling conversationsPushedMessagesIdDelete.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'DELETE', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body?: any; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Get an automated message * @param id ID of the message sent previously */ public async conversationsPushedMessagesIdGet (id: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }> { const localVarPath = this.basePath + '/conversations/pushedMessages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling conversationsPushedMessagesIdGet.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "ConversationsMessage"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Update an automated message * @param id ID of the message * @param body */ public async conversationsPushedMessagesIdPut (id: string, body: ConversationsPushedMessagesIdPutRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }> { const localVarPath = this.basePath + '/conversations/pushedMessages/{id}' .replace('{' + 'id' + '}', encodeURIComponent(String(id))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'id' is not null or undefined if (id === null || id === undefined) { throw new Error('Required parameter id was null or undefined when calling conversationsPushedMessagesIdPut.'); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling conversationsPushedMessagesIdPut.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(body, "ConversationsPushedMessagesIdPutRequest") }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "ConversationsMessage"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Example of automated messages: order status, announce new features in your web app, etc. * @summary Send an automated message to a visitor * @param body */ public async conversationsPushedMessagesPost (body: ConversationsPushedMessagesPostRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }> { const localVarPath = this.basePath + '/conversations/pushedMessages'; let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new Error('Required parameter body was null or undefined when calling conversationsPushedMessagesPost.'); } (<any>Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(body, "ConversationsPushedMessagesPostRequest") }; let authenticationPromise = Promise.resolve(); if (this.authentications.apiKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.apiKey.applyToRequest(localVarRequestOptions)); } if (this.authentications.partnerKey.apiKey) { authenticationPromise = authenticationPromise.then(() => this.authentications.partnerKey.applyToRequest(localVarRequestOptions)); } authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); let interceptorPromise = authenticationPromise; for (const interceptor of this.interceptors) { interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions)); } return interceptorPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (<any>localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.IncomingMessage; body: ConversationsMessage; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { body = ObjectSerializer.deserialize(body, "ConversationsMessage"); resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } }
- Type definitions and serialization mapping for ConversationsMessage, used for request/response validation and parsing in the conversations tool.export class ConversationsMessage { /** * Message ID. It can be used for further manipulations with the message. */ 'id'?: string; /** * `\"agent\"` for agents’ messages, `\"visitor\"` for visitors’ messages. */ 'type'?: ConversationsMessage.TypeEnum; /** * Message text or name of the attached file */ 'text'?: string; /** * visitor’s ID */ 'visitorId'?: string; /** * ID of the agent on whose behalf the message was sent (only in messages sent by an agent). */ 'agentId'?: string; /** * Agent’s name as displayed to the visitor. Only in the messages sent by an agent. */ 'agentName'?: string; /** * Timestamp in milliseconds. */ 'createdAt'?: number; /** * `true` for pushed messages */ 'isPushed'?: boolean; /** * In two-way integrations, messages sent via REST API can be marked with receivedFrom property and then filtered out when received in a webhook to avoid infinite loop. */ 'receivedFrom'?: string; 'file'?: ConversationsMessageFile; static discriminator: string | undefined = undefined; static attributeTypeMap: Array<{name: string, baseName: string, type: string}> = [ { "name": "id", "baseName": "id", "type": "string" }, { "name": "type", "baseName": "type", "type": "ConversationsMessage.TypeEnum" }, { "name": "text", "baseName": "text", "type": "string" }, { "name": "visitorId", "baseName": "visitorId", "type": "string" }, { "name": "agentId", "baseName": "agentId", "type": "string" }, { "name": "agentName", "baseName": "agentName", "type": "string" }, { "name": "createdAt", "baseName": "createdAt", "type": "number" }, { "name": "isPushed", "baseName": "isPushed", "type": "boolean" }, { "name": "receivedFrom", "baseName": "receivedFrom", "type": "string" }, { "name": "file", "baseName": "file", "type": "ConversationsMessageFile" } ]; static getAttributeTypeMap() { return ConversationsMessage.attributeTypeMap; } }