### Initialize Client and Send Message Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/README.md Quick start example demonstrating client initialization, authentication, sending a text message, and setting up a listener for incoming messages. ```javascript import { Crisp } from "crisp-api"; const client = new Crisp(); client.authenticateTier("plugin", identifier, key); // Send a message await client.website.sendMessageInConversation(websiteID, sessionID, { type: "text", from: "operator", origin: "chat", content: "Hello!" }); // Listen for events await client.on("message:send", (message) => { console.log("New message:", message.content); }); ``` -------------------------------- ### Generate Helpdesk Domain Setup Flow Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Generates a setup flow for a custom helpdesk domain. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var custom = "help.valeriansaliou.name"; CrispClient.website.generateHelpdeskDomainSetupFlow(websiteID, custom); ``` -------------------------------- ### Generate Helpdesk Domain Setup Flow Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Generates a setup flow for the helpdesk domain of a given website. ```APIDOC ## Generate Helpdesk Domain Setup Flow ### Description Generates a setup flow for the helpdesk domain of a given website. ### Method POST ### Endpoint /websites/{website_id}/helpdesk/domain/setup ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. #### Request Body - **custom** (string) - Required - The custom domain name. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var custom = "help.valeriansaliou.name"; CrispClient.website.generateHelpdeskDomainSetupFlow(websiteID, custom); ``` ``` -------------------------------- ### Minimal Crisp API Client Setup Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/configuration.md Initialize the Crisp client with minimal configuration and authenticate using an identifier and key. This is the basic setup for most operations. ```javascript import { Crisp } from "crisp-api"; const client = new Crisp(); // Authenticate with identifier and key client.authenticate("YOUR_IDENTIFIER", "YOUR_KEY"); // Use the client const conversations = await client.website.listConversations(websiteID, 1); ``` -------------------------------- ### Generate Helpdesk Domain Setup Flow Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Generates a setup flow for a helpdesk domain. This requires the website ID and the custom domain name. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var custom = "help.valeriansaliou.name"; CrispClient.website.generateHelpdeskDomainSetupFlow(websiteID, custom); ``` -------------------------------- ### Install Node Crisp API Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/INDEX.md Installs the Node Crisp API package using npm. This is the first step for setting up the client. ```bash npm install --save crisp-api ``` -------------------------------- ### Initialize Helpdesk for a Website Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Initialize a new helpdesk for a website, providing a name and a basic domain. This is a setup operation for a new helpdesk. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var name = "Valerian Helpdesk"; var domainBasic = "valerian"; CrispClient.website.initializeHelpdesk(websiteID, name, domainBasic); ``` -------------------------------- ### CrispClient.website.importPeopleProfiles Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Imports people profiles into a website. Requires website ID and profile import setup object. ```APIDOC ## CrispClient.website.importPeopleProfiles ### Description Imports people profiles into a website. ### Method Not specified (likely POST) ### Endpoint Not specified ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **profileImportSetup** (object) - Required - An object containing the setup for profile import. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.importPeopleProfiles(websiteID, profileImportSetup); ``` ### Response #### Success Response (200) Not specified #### Response Example Not specified ``` -------------------------------- ### get Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/api-reference/crisp-client.md Sends a GET request to the specified resource. Used for retrieving data from the API. ```APIDOC ## get(resource: string, query?: object): Promise ### Description Sends a GET request to the specified resource. ### Method GET ### Parameters #### Path Parameters - **resource** (string) - Yes - Full resource URL #### Query Parameters - **query** (object) - No - Query parameters ### Request Example ```typescript const conversations = await client.get("/v1/website/website-id/conversations/1", { per_page: 50 }); ``` ### Returns Promise that resolves with response data. ``` -------------------------------- ### Initialize Helpdesk Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Initializes the helpdesk for a given website. Requires website ID, name, and domain. ```javascript CrispClient.website.initializeHelpdesk(websiteID, name, domainBasic); ``` -------------------------------- ### Get Website Verify Settings Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the verify settings for a given website. Requires the website ID. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.getVerifySettings(websiteID); ``` -------------------------------- ### Initialize Helpdesk Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Initializes a helpdesk for a given website with a name and basic domain. Requires website ID, name, and domain. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var name = "Valerian Helpdesk"; var domainBasic = "valerian"; // Note: The actual CrispClient.website.initializeHelpdesk call is missing in the source. ``` -------------------------------- ### Initialize Helpdesk Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Initializes a helpdesk for a given website ID with a specified name and basic domain. ```APIDOC ## initializeHelpdesk ### Description Initializes a helpdesk for a given website ID with a specified name and basic domain. ### Method `CrispClient.website.initializeHelpdesk(websiteID, name, domainBasic)` ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website. - **name** (string) - Required - The name of the helpdesk. - **domainBasic** (string) - Required - The basic domain for the helpdesk. ``` -------------------------------- ### Perform GET Request Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/api-reference/crisp-client.md Send a GET request to a specific API resource. Use this to retrieve data from Crisp. ```typescript const conversations = await client.get("/v1/website/website-id/conversations/1", { per_page: 50 }); ``` -------------------------------- ### Import People Profiles Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Imports people profiles into a website. Requires website ID and a profile import setup object. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; ``` -------------------------------- ### Get Connected Plugin Account Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/api-reference/plugin-service.md Retrieves information about the currently connected plugin account. Use this to get the plugin ID. ```typescript const account = await client.plugin.getConnectAccount(); console.log("Plugin ID:", account.plugin_id); ``` -------------------------------- ### Configure Crisp Client Resources Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/configuration.md This example shows how to configure various client resources, including the REST host, RTM mode, custom headers, and authentication, all before making the first API call. ```javascript // Set all configuration before first API call const client = new Crisp(); client.setRestHost(process.env.CRISP_REST_HOST); client.setRtmMode("webhooks"); client.setCustomHeaders({ "X-App-ID": "my-app" }); client.authenticate(id, key); // Now use the client const result = await client.website.listConversations(websiteID, 1); ``` -------------------------------- ### CrispClient.website.initializeHelpdesk Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Initializes the helpdesk for a given website. This method requires the website ID, a name for the helpdesk, and basic domain information. ```APIDOC ## CrispClient.website.initializeHelpdesk ### Description Initializes the helpdesk for a given website. This method requires the website ID, a name for the helpdesk, and basic domain information. ### Method POST ### Endpoint /websites/{website_id}/helpdesk ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. #### Request Body - **name** (string) - Required - The name of the helpdesk. - **domain_basic** (object) - Required - Basic domain information. ``` -------------------------------- ### List Animation Medias Example Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/api-reference/plan-and-media-services.md Demonstrates how to list animation media resources using the Media service. Requires the 'plugin' authentication tier. ```typescript const animations = await client.media.listAnimationMedias(1, "reactions", { search_term: "thumbs" }); animations.forEach(animation => { console.log(`Animation: ${animation.name}, URL: ${animation.url}`); }); ``` -------------------------------- ### Get a Website Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves details for a specific website. ```APIDOC ## Get a Website ### Description Retrieves details for a specific website. ### Method GET ### Endpoint /websites/{website_id} ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.getWebsite(websiteID); ``` ``` -------------------------------- ### Full Upload Flow Example Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/api-reference/bucket-service.md Demonstrates the complete process of generating a signed upload URL, uploading a file using that URL, and then referencing the file in a message. ```typescript // 1. Get signed upload URL const bucketData = await client.bucket.generateBucketURL({ namespace: "upload", id: sessionID, file: { name: "document.pdf", type: "application/pdf" }, resource: { type: "conversation", id: sessionID } }); // 2. Upload file to the provided URL (using your HTTP client) const fileContent = fs.readFileSync("./document.pdf"); await fetch(bucketData.url, { method: "PUT", headers: { "Content-Type": "application/pdf" }, body: fileContent }); // 3. Use the bucket key in your message await client.website.sendMessageInConversation(websiteID, sessionID, { type: "file", from: "operator", origin: "chat", content: { name: "document.pdf", url: bucketData.url, // or use bucketData.key depending on requirements type: "application/pdf" } }); ``` -------------------------------- ### Get Connect Endpoints Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Retrieves the connect endpoints for a website. ```APIDOC ## Get Connect Endpoints ### Description Retrieves the connect endpoints for a website. ### Method `CrispClient.website.getConnectEndpoints(websiteID)` ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.getConnectEndpoints(websiteID); ``` ``` -------------------------------- ### Get Website Settings Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the settings for a specific website. ```APIDOC ## Get Website Settings ### Description Retrieves the settings for a specific website. ### Method GET ### Endpoint /websites/{website_id}/settings ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.getWebsiteSettings(websiteID); ``` ``` -------------------------------- ### Get Conversation Participants Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the list of participants in a conversation. ```APIDOC ## Get Conversation Participants ### Description Lists all participants involved in a specific conversation. ### Method GET (assumed based on typical REST API patterns for listing resources) ### Endpoint `/websites/{website_id}/sessions/{session_id}/participants` (inferred from documentation structure) ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. - **session_id** (string) - Required - The ID of the conversation session. ### Request Example ```javascript CrispClient.website.getConversationParticipants("website_id", "session_id"); ``` ### Response #### Success Response (200) - **participants** (array) - An array of participant objects. ``` -------------------------------- ### Get Conversation Relations Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves information about the relations of a conversation. ```APIDOC ## Get Conversation Relations ### Description Fetches details about the relationships or associated entities of a conversation. ### Method GET (assumed based on typical REST API patterns for retrieving related resources) ### Endpoint `/websites/{website_id}/sessions/{session_id}/relations` (inferred from documentation structure) ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. - **session_id** (string) - Required - The ID of the conversation session. ### Request Example ```javascript CrispClient.website.getConversationRelations("website_id", "session_id"); ``` ### Response #### Success Response (200) - **relations** (object) - An object containing information about the conversation's relations. ``` -------------------------------- ### Setup Crisp API Client from Environment Variables Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/configuration.md Initialize and authenticate the Crisp client using values from environment variables. This allows for flexible configuration without hardcoding credentials. ```javascript const client = new Crisp(); client.authenticateTier( process.env.CRISP_TIER || "user", process.env.CRISP_IDENTIFIER, process.env.CRISP_KEY ); if (process.env.CRISP_REST_HOST) { client.setRestHost(process.env.CRISP_REST_HOST); } if (process.env.CRISP_RTM_MODE) { client.setRtmMode(process.env.CRISP_RTM_MODE); } ``` -------------------------------- ### Get Conversation State Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the current state of a conversation. ```APIDOC ## Get Conversation State ### Description Fetches the current status (e.g., open, resolved) of a conversation. ### Method GET (assumed based on typical REST API patterns for retrieving a resource's state) ### Endpoint `/websites/{website_id}/sessions/{session_id}/state` (inferred from documentation structure) ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. - **session_id** (string) - Required - The ID of the conversation session. ### Request Example ```javascript CrispClient.website.getConversationState("website_id", "session_id"); ``` ### Response #### Success Response (200) - **state** (string) - The current state of the conversation (e.g., "resolved", "unresolved"). ``` -------------------------------- ### Handle Authentication Errors Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/errors-and-edge-cases.md Example of how to catch and handle a 401 authentication failed error. Ensure your identifier and key are correct. ```javascript try { const client = new Crisp(); client.authenticate("invalid_id", "invalid_key"); const result = await client.website.listConversations(websiteID, 1); } catch (error) { if (error.code === 401) { console.error("Authentication failed - invalid credentials"); } } ``` -------------------------------- ### CrispClient.website.resolveHelpdeskSettings Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Retrieves the helpdesk settings for a given website. ```APIDOC ## CrispClient.website.resolveHelpdeskSettings ### Description Retrieves the helpdesk settings for a given website. ### Method Not specified, likely a GET request. ### Endpoint Not specified. ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website. ### Request Example ```javascript CrispClient.website.resolveHelpdeskSettings(websiteID); ``` ### Response #### Success Response (200) Details of the response are not specified in the source. ``` -------------------------------- ### Get Conversation Metas Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the metadata associated with a conversation. ```APIDOC ## GET CONVERSATION METAS ### Description Retrieves the metadata associated with a conversation. ### Method GET ### Endpoint /websites/{websiteID}/sessions/{sessionID}/metas ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website. - **sessionID** (string) - Required - The ID of the conversation session. ### Response #### Success Response (200) - **metas** (object) - The metadata of the conversation. ``` -------------------------------- ### Get A Website Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Retrieves details for a specific website using its ID. ```APIDOC ## Get A Website ### Description Retrieves details for a specific website using its ID. ### Method GET ### Endpoint `/websites/{websiteID}` ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website to retrieve. ### Request Example ```json { "websiteID": "8c842203-7ed8-4e29-a608-7cf78a7d2fcc" } ``` ### Response (Response details not provided in the source) ``` -------------------------------- ### Initialize Crisp Client Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/DOCUMENTATION-MANIFEST.txt Instantiate the Crisp client with your API credentials. This is the first step before making any API calls. ```javascript import Crisp from "crisp-api"; const crisp = new Crisp(process.env.API_TOKEN, process.env.WEBSITE_ID); ``` -------------------------------- ### Get Plugin Attest Provenance Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the attestation provenance for a plugin. ```APIDOC ## Get Plugin Attest Provenance ### Description Fetches the attestation provenance information for a specific plugin. ### Method GET ### Endpoint `/v1/websites/{website_id}/plugins/{plugin_id}/attest/provenance` ### Parameters #### Path Parameters - **website_id** (string) - Required - The unique identifier of the website. - **plugin_id** (string) - Required - The unique identifier of the plugin. ### Request Example ```javascript CrispClient.plugin.getPluginAttestProvenance("8c842203-7ed8-4e29-a608-7cf78a7d2fcc", "c64f3595-adee-425a-8d3a-89d47f7ed6bb"); ``` ### Response #### Success Response (200) - **data** (object) - The attestation provenance details. #### Response Example ```json { "data": { "version": "1.0.0", "timestamp": "2023-01-01T12:00:00Z" } } ``` ``` -------------------------------- ### Set Up Real-Time Event Listener Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/README.md Configure the client for real-time messaging and register listeners for specific events like new messages or session removals. Ensure all listeners are registered before establishing the connection. ```javascript const client = new Crisp(); client.authenticateTier("plugin", identifier, key); client.setRtmMode("websockets"); // or "webhooks" // Register ALL listeners before connection await client.on("message:send", (message) => { handleNewMessage(message); }); await client.on("session:removed", (data) => { handleSessionClosed(data.session_id); }); console.log("Listening for events..."); ``` -------------------------------- ### Get Subscription Settings Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the current settings for a plugin subscription. ```APIDOC ## Get Subscription Settings ### Description Fetches the configuration settings for a specific plugin subscription on a website. ### Method GET ### Endpoint `/v1/websites/{website_id}/plugins/{plugin_id}/settings` ### Parameters #### Path Parameters - **website_id** (string) - Required - The unique identifier of the website. - **plugin_id** (string) - Required - The unique identifier of the plugin. ### Request Example ```javascript CrispClient.plugin.getSubscriptionSettings("8c842203-7ed8-4e29-a608-7cf78a7d2fcc", "c64f3595-adee-425a-8d3a-89d47f7ed6bb"); ``` ### Response #### Success Response (200) - **data** (object) - The subscription settings. #### Response Example ```json { "data": { "chatbox": { "25": "#bbbbbb" } } } ``` ``` -------------------------------- ### Create a Bot to Respond to Messages Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Sets up a listener for incoming 'message:send' events and responds with a predefined text message. Ensure authentication is done before setting up the listener. ```javascript var { Crisp } = require("crisp-api"); var CrispClient = new Crisp(); CrispClient.authenticateTier("plugin", identifier, key); // Notice: make sure to authenticate before listening for an event CrispClient.on("message:send", function(message) { CrispClient.website.sendMessageInConversation( message.website_id, message.session_id, { type : "text", content : "I'm a bot", from : "operator", // or user origin : "chat" } ) .then(function(message) { console.log("Message sent:", message); }) .catch(function(error) { console.error("Error sending message:", error); }); }) .then(function() { console.error("Requested to listen to sent messages"); }) .catch(function(error) { console.error("Failed listening to sent messages:", error); }); ``` -------------------------------- ### Get Connect Endpoints Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the general connect endpoints available. ```APIDOC ## GET /me/connect/endpoints ### Description Retrieves the general connect endpoints available. ### Method GET ### Endpoint /me/connect/endpoints ``` -------------------------------- ### Create Website Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Creates a new website with the provided website data. ```javascript CrispClient.website.createWebsite(websiteData); ``` -------------------------------- ### CrispClient.website.saveHelpdeskSettings Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Saves the helpdesk settings for a given website. ```APIDOC ## CrispClient.website.saveHelpdeskSettings ### Description Saves the helpdesk settings for a given website. ### Method Not specified, likely a POST or PUT request. ### Endpoint Not specified. ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website. - **settings** (object) - Required - An object containing the helpdesk settings to save. ### Request Body - **settings** (object) - Required - An object containing the helpdesk settings to save. - **name** (string) - Optional - The name of the helpdesk. ### Request Example ```javascript var settings = { "name": "Valerian Helpdesk" }; CrispClient.website.saveHelpdeskSettings(websiteID, settings); ``` ### Response #### Success Response (200) Details of the response are not specified in the source. ``` -------------------------------- ### Get Connect Account Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves information about the current connect account. ```APIDOC ## GET /me/connect/account ### Description Retrieves information about the current connect account. ### Method GET ### Endpoint /me/connect/account ``` -------------------------------- ### Plugin Connect - List Connect Websites Since Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Lists connect websites created since a specified date. ```APIDOC ## Plugin Connect - List Connect Websites Since ### Description Lists connect websites created since a specified date, with options for filtering. ### Method `CrispClient.plugin.listConnectWebsitesSince(dateSince, filterConfigured, includePlan)` ### Endpoint [Reference](https://docs.crisp.chat/references/rest-api/v1/#list-connect-websites-since) ### Parameters #### Query Parameters - **dateSince** (string) - Required - The date to filter websites from (ISO 8601 format). - **filterConfigured** (boolean) - Optional - Filter by configured websites. - **includePlan** (boolean) - Optional - Include plan details. ### Request Example ```javascript var dateSince = "2023-08-16T09:00:00Z"; CrispClient.plugin.listConnectWebsitesSince(dateSince, filterConfigured, includePlan); ``` ### Response (Details not provided in source) ``` -------------------------------- ### Get Connect Account Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Fetch information about the current connect account. ```javascript CrispClient.plugin.getConnectAccount(); ``` -------------------------------- ### Get a Website Operator Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves details for a specific website operator. ```APIDOC ## Get a Website Operator ### Description Retrieves details for a specific website operator. ### Method GET ### Endpoint /websites/{websiteID}/operators/{userID} ### Parameters #### Path Parameters - **websiteID** (string) - Required - The unique identifier of the website. - **userID** (string) - Required - The unique identifier of the operator. ### Response #### Success Response (200) - **operator** (object) - The website operator object. #### Response Example ```json { "operator": { "id": "a4c32c68-be91-4e29-8a05-976e93abbe3f", "email": "operator@example.com", "role": "member", "title": "Operator" } } ``` ``` -------------------------------- ### Create Website Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Creates a new website. ```APIDOC ## Create Website ### Description Creates a new website. ### Method POST ### Endpoint /websites ### Parameters #### Request Body - **websiteData** (object) - Required - An object containing the data for the new website. ### Request Example ```javascript CrispClient.website.createWebsite(websiteData); ``` ``` -------------------------------- ### Setup Webhook Server with Node.js and Express Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/configuration.md This snippet demonstrates how to set up an Express.js server to receive and process webhooks from Crisp. It includes authentication for the webhook signature and error handling for incoming events. ```javascript import express from "express"; import { Crisp } from "crisp-api"; const app = express(); const client = new Crisp(); client.authenticateTier("plugin", identifier, key); client.setRtmMode("webhooks"); // Register event listeners (still needed for webhook routing) await client.on("message:send", (message) => { console.log("Message:", message); }); // Webhook endpoint to receive events app.post("/webhook", (req, res) => { // Verify webhook signature const webhookSecret = process.env.CRISP_WEBHOOK_SECRET; const timestamp = parseInt(req.headers["x-crisp-timestamp"]); const signature = req.headers["x-crisp-signature"]; if (!client.verifyHook(webhookSecret, req.body, timestamp, signature)) { console.error("Invalid webhook signature"); return res.status(401).json({ error: "Invalid signature" }); } // Process the webhook const error = client.receiveHook(req.body); if (error) { console.error("Webhook processing error:", error); return res.status(400).json({ error: error.message }); } // Success res.json({ status: "ok" }); }); app.listen(3000, () => { console.log("Webhook server listening on port 3000"); }); ``` -------------------------------- ### Count Visitors Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Get the total number of visitors for a given website. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.countVisitors(websiteID); ``` -------------------------------- ### Recommended Event Listener Pattern Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/rtm-events.md A robust pattern for setting up event listeners in production environments, including error handling for registration failures. ```javascript // Recommended pattern for production async function setupEventListeners(client) { try { await client.on("message:send", (data) => { // data structure varies by event type console.log("Event received:", data); }); await client.on("message:received", (data) => { console.log("Message received from user:", data); }); await client.on("session:removed", (data) => { console.log("Conversation closed:", data.session_id); }); console.log("Event listeners registered successfully"); } catch (error) { console.error("Failed to register event listeners:", error); } } await setupEventListeners(client); ``` -------------------------------- ### Get Website Settings Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the current settings for a specific website. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.getWebsiteSettings(websiteID); ``` -------------------------------- ### Get Website Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves details for a specific website using its ID. ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; CrispClient.website.getWebsite(websiteID); ``` -------------------------------- ### Crisp Client Methods Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/DOCUMENTATION-MANIFEST.txt Documentation for the Crisp class constructor, authentication, configuration, HTTP method wrappers, real-time messaging, and utility methods. ```APIDOC ## Crisp Client ### Description Provides access to the Crisp API client, including methods for authentication, configuration, making HTTP requests, and handling real-time messaging. ### Methods - **constructor**: Initializes the Crisp client. - **authenticate**: Methods for authenticating with the Crisp API. - **configure**: Methods for configuring the API client. - **http**: Wrappers for common HTTP methods (HEAD, GET, POST, PATCH, PUT, DELETE). - **rtm**: Methods for real-time messaging (on, receiveHook, verifyHook, rebindSocket). - **utils**: Utility methods like `prepareRestUrl`. ### Properties - **services**: Access to various service objects (e.g., website, plugin). ### Examples Refer to `crisp-client.md` for detailed usage examples and source file references. ``` -------------------------------- ### Get Verify Status for Conversation Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the verification status of a conversation. ```APIDOC ## Get Verify Status for Conversation ### Description Checks the current identity verification status for a conversation. ### Method GET (assumed based on typical REST API patterns for retrieving status) ### Endpoint `/websites/{website_id}/sessions/{session_id}/verify` (inferred from documentation structure) ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. - **session_id** (string) - Required - The ID of the conversation session. ### Request Example ```javascript CrispClient.website.getVerifyStatusForConversation("website_id", "session_id"); ``` ### Response #### Success Response (200) - **verified** (boolean) - True if the conversation is verified, false otherwise. ``` -------------------------------- ### Initialize Crisp Client Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/api-reference/crisp-client.md Create a new instance of the Crisp API client. ```typescript const client = new Crisp(); ``` -------------------------------- ### Get a Conversation Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves details of a specific conversation for a given website. ```APIDOC ## Get a Conversation ### Description Retrieves details of a specific conversation for a given website. ### Method GET ### Endpoint /websites/{website_id}/conversations/{session_id} ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. - **session_id** (string) - Required - The ID of the conversation session to retrieve. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var sessionID = "session_700c65e1-85e2-465a-b9ac-ecb5ec2c9881"; CrispClient.website.getConversation(websiteID, sessionID); ``` ### Response #### Success Response (200) - **data** (object) - The conversation object. ``` -------------------------------- ### Crisp API Client Setup with Tier Specification Source: https://github.com/crisp-im/node-crisp-api/blob/master/_autodocs/configuration.md Initialize and authenticate the Crisp client specifying the authentication tier (e.g., 'plugin') in a single call. Useful for accessing tier-specific methods. ```javascript const client = new Crisp(); // Set tier and authenticate in one call client.authenticateTier("plugin", identifier, key); // Now you can use plugin-specific methods const account = await client.plugin.getConnectAccount(); ``` -------------------------------- ### CrispClient.website.getVerifySettings Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Retrieves the verify settings for a website. ```APIDOC ## CrispClient.website.getVerifySettings ### Description Retrieves the verify settings for a website. ### Method Not specified (assumed to be a client-side SDK method) ### Endpoint Not specified ### Parameters - **websiteID** (string) - Required - The ID of the website. ``` -------------------------------- ### Get Subscription Details Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the details of a specific plugin subscription for a website. ```APIDOC ## Get Subscription Details ### Description Fetches detailed information about a specific plugin subscription for a given website. ### Method GET ### Endpoint `/v1/websites/{website_id}/plugins/{plugin_id}/subscription` ### Parameters #### Path Parameters - **website_id** (string) - Required - The unique identifier of the website. - **plugin_id** (string) - Required - The unique identifier of the plugin. ### Request Example ```javascript CrispClient.plugin.getSubscriptionDetails("8c842203-7ed8-4e29-a608-7cf78a7d2fcc", "c64f3595-adee-425a-8d3a-89d47f7ed6bb"); ``` ### Response #### Success Response (200) - **data** (object) - The subscription details. - **plugin_id** (string) - The ID of the plugin. - **created_at** (string) - Timestamp when the subscription was created. - **updated_at** (string) - Timestamp when the subscription was last updated. #### Response Example ```json { "data": { "plugin_id": "c64f3595-adee-425a-8d3a-89d47f7ed6bb", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } } ``` ``` -------------------------------- ### Get Website Connect Endpoints Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the connect endpoints for a specific website. ```APIDOC ## GET /websites/{website_id}/connect/endpoints ### Description Retrieves the connect endpoints for a specific website. ### Method GET ### Endpoint /websites/{website_id}/connect/endpoints ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. ``` -------------------------------- ### CrispClient.website.importExternalHelpdeskToLocale Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Imports an external helpdesk to a specified website locale. ```APIDOC ## CrispClient.website.importExternalHelpdeskToLocale ### Description Imports an external helpdesk to a specified website locale. ### Method Not specified, likely a POST request. ### Endpoint Not specified. ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website. - **locale** (string) - Required - The locale to import the helpdesk to. - **helpdeskUrl** (string) - Required - The URL of the external helpdesk. ### Request Example ```javascript CrispClient.website.importExternalHelpdeskToLocale(websiteID, locale, helpdeskUrl); ``` ### Response #### Success Response (200) Details of the response are not specified in the source. ``` -------------------------------- ### CrispClient.website.initiateBrowsingSessionForConversation Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Initiates a new browsing session for a conversation. Requires website ID and session ID. ```APIDOC ## CrispClient.website.initiateBrowsingSessionForConversation ### Description Initiates a new browsing session for a conversation. Requires website ID and session ID. ### Method Signature `CrispClient.website.initiateBrowsingSessionForConversation(websiteID, sessionID)` ### Parameters * **websiteID** (string) - Required - The ID of the website. * **sessionID** (string) - Required - The ID of the conversation session. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var sessionID = "session_700c65e1-85e2-465a-b9ac-ecb5ec2c9881"; CrispClient.website.initiateBrowsingSessionForConversation(websiteID, sessionID); ``` ``` -------------------------------- ### Get Block Status for Conversation Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Checks if incoming messages are blocked for a conversation. ```APIDOC ## Get Block Status for Conversation ### Description Determines whether incoming messages are currently blocked for a given conversation. ### Method GET (assumed based on typical REST API patterns for retrieving status) ### Endpoint `/websites/{website_id}/sessions/{session_id}/block` (inferred from documentation structure) ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. - **session_id** (string) - Required - The ID of the conversation session. ### Request Example ```javascript CrispClient.website.getBlockStatusForConversation("website_id", "session_id"); ``` ### Response #### Success Response (200) - **blocked** (boolean) - True if messages are blocked, false otherwise. ``` -------------------------------- ### Get a Message in Conversation Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves a specific message from a conversation for a given website. ```APIDOC ## Get a Message in Conversation ### Description Retrieves a specific message from a conversation for a given website. ### Method GET ### Endpoint /websites/{website_id}/conversations/{session_id}/messages/{fingerprint} ### Parameters #### Path Parameters - **website_id** (string) - Required - The ID of the website. - **session_id** (string) - Required - The ID of the conversation session. - **fingerprint** (integer) - Required - The fingerprint of the message to retrieve. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var sessionID = "session_700c65e1-85e2-465a-b9ac-ecb5ec2c9881"; var fingerprint = 524653764345; CrispClient.website.getMessageInConversation(websiteID, sessionID, fingerprint); ``` ### Response #### Success Response (200) - **data** (object) - The message object. ``` -------------------------------- ### CrispClient.website.listHelpdeskLocaleFeedbacks Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Lists helpdesk locale feedbacks for a given website and locale. ```APIDOC ## CrispClient.website.listHelpdeskLocaleFeedbacks ### Description Lists helpdesk locale feedbacks for a given website and locale. ### Method Signature `CrispClient.website.listHelpdeskLocaleFeedbacks(websiteID, locale)` ### Parameters - **websiteID** (string) - Required - The ID of the website. - **locale** (string) - Required - The locale code (e.g., "en"). ``` -------------------------------- ### Plugin Subscription - Get Subscription Details Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Retrieves the details for a specific subscription on a website. ```APIDOC ## Plugin Subscription - Get Subscription Details ### Description Retrieves the details of a specific subscription for a given website and plugin. ### Method `CrispClient.plugin.getSubscriptionDetails(websiteID, pluginID)` ### Endpoint [Reference](https://docs.crisp.chat/references/rest-api/v1/#get-subscription-details) ### Parameters #### Path Parameters - **websiteID** (string) - Required - The ID of the website. - **pluginID** (string) - Required - The ID of the plugin. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var pluginID = "c64f3595-adee-425a-8d3a-89d47f7ed6bb"; CrispClient.plugin.getSubscriptionDetails(websiteID, pluginID); ``` ### Response (Details not provided in source) ``` -------------------------------- ### listHelpdeskLocaleSections Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Lists all helpdesk sections for a specific website, locale, and category, with pagination. ```APIDOC ## CrispClient.website.listHelpdeskLocaleSections ### Description Lists all helpdesk sections for a specific website, locale, and category, with pagination. ### Method Signature `CrispClient.website.listHelpdeskLocaleSections(websiteID, locale, categoryId, pageNumber)` ### Parameters * **websiteID** (string) - The ID of the website. * **locale** (string) - The locale of the sections. * **categoryId** (string) - The ID of the category to list sections from. * **pageNumber** (number) - The page number for pagination. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var locale = "en"; var categoryId = "33bc73b7-b7db-40a9-80fc-fcba8ebd1067"; // pageNumber is optional and not provided in the example, but would be a number. CrispClient.website.listHelpdeskLocaleSections(websiteID, locale, categoryId); ``` ``` -------------------------------- ### Get Plan Subscription for a Website Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the plan subscription details for a specific website. ```APIDOC ## Get Plan Subscription for a Website ### Description Fetches the details of the current plan subscription for a given website. ### Method GET ### Endpoint `/v1/websites/{website_id}/plan/subscription` ### Parameters #### Path Parameters - **website_id** (string) - Required - The unique identifier of the website. ### Request Example ```javascript CrispClient.plan.getPlanSubscriptionForWebsite("8c842203-7ed8-4e29-a608-7cf78a7d2fcc"); ``` ### Response #### Success Response (200) - **data** (object) - The plan subscription details. - **plan_id** (string) - The ID of the plan. - **status** (string) - The status of the subscription (e.g., "active"). - **created_at** (string) - Timestamp when the subscription was created. - **updated_at** (string) - Timestamp when the subscription was last updated. #### Response Example ```json { "data": { "plan_id": "d678dbc1-e49d-47d3-92f2-c436f5b0e4a5", "status": "active", "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } } ``` ``` -------------------------------- ### CrispClient.website.initiateNewCallSessionForConversation Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Initiates a new call session (audio or video) for a conversation. Requires website ID, session ID, call mode, user details, and origin. ```APIDOC ## CrispClient.website.initiateNewCallSessionForConversation ### Description Initiates a new call session (audio or video) for a conversation. Requires website ID, session ID, call mode, user details, and origin. ### Method Signature `CrispClient.website.initiateNewCallSessionForConversation(websiteID, sessionID, mode, user, origin)` ### Parameters * **websiteID** (string) - Required - The ID of the website. * **sessionID** (string) - Required - The ID of the conversation session. * **mode** (string) - Required - The call mode ('audio' or 'video'). * **user** (object) - Required - User details for the call. * **origin** (string) - Required - The origin of the call. ### Request Example ```javascript var websiteID = "8c842203-7ed8-4e29-a608-7cf78a7d2fcc"; var sessionID = "session_700c65e1-85e2-465a-b9ac-ecb5ec2c9881"; var mode = "audio"; // Additional parameters for user and origin would be included here. // CrispClient.website.initiateNewCallSessionForConversation(websiteID, sessionID, mode, user, origin); ``` ``` -------------------------------- ### Get Connect Endpoints (Plugin) Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieve connect endpoints available through the plugin interface. ```javascript CrispClient.plugin.getConnectEndpoints(); ``` -------------------------------- ### Get Session Identifier from Token Source: https://github.com/crisp-im/node-crisp-api/blob/master/EXAMPLES.md Retrieves the session identifier associated with a given token. ```APIDOC ## Get Session Identifier from Token ### Description Retrieves the session identifier associated with a given token. ### Method GET ### Endpoint /websites/{websiteID}/sessions/{tokenID} ### Parameters #### Path Parameters - **websiteID** (string) - Required - The unique identifier of the website. - **tokenID** (string) - Required - The token for which to retrieve the session identifier. ### Response #### Success Response (200) - **session_id** (string) - The session identifier. ``` -------------------------------- ### CrispClient.website.listHelpdeskLocaleSections Source: https://github.com/crisp-im/node-crisp-api/blob/master/README.md Lists helpdesk locale sections for a given website, locale, and category. Supports pagination. ```APIDOC ## CrispClient.website.listHelpdeskLocaleSections ### Description Lists helpdesk locale sections for a given website, locale, and category. Supports pagination. ### Method Signature `CrispClient.website.listHelpdeskLocaleSections(websiteID, locale, categoryId, pageNumber)` ### Parameters - **websiteID** (string) - Required - The ID of the website. - **locale** (string) - Required - The locale code (e.g., "en"). - **categoryId** (string) - Required - The ID of the category. - **pageNumber** (number) - Optional - The page number for pagination. ```