Skip to content

Utilities | @chatally/utils

The ChatAlly utilities are published as separate package @chatally/utils on npmjs.com. Find the sources on Github.

Install the utilities by

Terminal window
npm install @chatally/utils

Chat Messages

There are a few utilities to create chat messages, particularly for Media messages.

image: Create an Image chat message

/**
* @param url
* An URL or path referencing the media asset. For paths (without protocol),
* 'file://' is prepended. Relative paths are resolved against the current
* working directory (`process.cwd()`).
* @param caption
* [Optional] caption for the media asset
* @param description
* [Optional] description for the image asset
* @returns An Image chat message
*/
export declare function image(url: string, caption?: string, description?: string): Image

audio: Create an Audio chat message

/**
* @param url
* An URL or path referencing the media asset. For paths (without protocol),
* 'file://' is prepended. Relative paths are resolved against the current
* working directory (`process.cwd()`).
* @param caption
* [Optional] caption for the media asset
* @param transcript
* [Optional] transcript for the audio asset
* @returns An Audio chat message
*/
export declare function audio(url: string, caption?: string, transcript?: string): Audio

video: Create a Video chat message

/**
* @param url
* An URL or path referencing the media asset. For paths (without protocol),
* 'file://' is prepended. Relative paths are resolved against the current
* working directory (`process.cwd()`).
* @param caption
* [Optional] caption for the media asset
* @param transcript
* [Optional] transcript for the video asset
* @returns A Video chat message
*/
export declare function video(url: string, caption?: string, transcript?: string): Video

document: Create a Document chat message

/**
* @param url
* An URL or path referencing the media asset. For paths (without protocol),
* 'file://' is prepended. Relative paths are resolved against the current
* working directory (`process.cwd()`).
* @param caption
* [Optional] caption for the media asset
* @param description
* [Optional] description for the document asset
* @param filename
* [Optional] original filename of the asset
* @returns An Audio chat message
*/
export declare function document(url: string, caption?: string, description?: string, filename?: string): Document

content: Get a textual description of the message

/**
* @param {import('@chatally/core').ChatMessage | import('@chatally/core').Action} msg Any chat message
* @returns {string}
* A textual description of the message, the actual returned value depends
* on the type of message.
*/
export declare function content(message: ChatMessage | Action): string