Giter Site home page Giter Site logo

chatwoot-sdk's Introduction

Chatwoot API SDK

npm (scoped) GitHub Workflow Status (with branch) NPM

The Chatwoot SDK is a JavaScript client that allows developers to connect to the Chatwoot API. With full TypeScript support, the SDK provides an easy-to-use interface for developers to interact with the Chatwoot platform programmatically.

The SDK is built with simplicity in mind and only depends on Axios for advanced data fetching support and compatibility. This means that developers can enjoy a lightweight, efficient SDK without the added burden of extraneous dependencies.

To learn more about the Chatwoot API, please refer to Chatwoot's documentation. There, you'll find everything you need to get started, including detailed API reference documentation, sample code, and tutorials.

Installation

Using npm:

npm i @figuro/chatwoot-sdk --save

Using yarn:

yarn add @figuro/chatwoot-sdk

Example

import ChatwootClient from "@figuro/chatwoot-sdk";

const client = new ChatwootClient({
    config: {
        basePath: "https://app.chatwoot.com",
        with_credentials: true,
        credentials: "include",
        token: "<YOUR_API_TOKEN_HERE>"
    }
});

client.messages.create({
    accountId: 1,
    conversationId: 8,
    data: {
        content: "Hello, World!"
    }
})
    .then(response => {
        console.log(response.sender?.name);
    })
    .catch(err => {
        console.error(err);
    });

While not documented on Chatwoot, file messages are supported via multipart/form-data, to enable this, an attachment parameter is implemented. (Please note that content was shortened for simplicity and is not valid).

client.messages.create({
    accountId: 1,
    conversationId: 8,
    data: {
        content: "Hello, World!",
        attachments: [
            {
                content: "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/...gUaFFSdABUVmZpaSnFk7kXiPwNOgbDxE5JKbEAAAAASUVORK5CYII=",
                encoding: "base64",
                filename: "test.png"
            }
        ]
    }
})
    .then(response => {
        console.log(response.sender?.name);
    })
    .catch(err => {
        console.error(err);
    });

Documentation

The full documentation for the Chatwoot API can be found Chatwoot's documentation.

Contributing

If you'd like to contribute, please open an issue or pull request on this repository. We'd love to hear from you!

License

This SDK is licensed under the MIT License.

Support

If you have any questions or need help, please reach out to us by opening an issue on this repository.

chatwoot-sdk's People

Contributors

carlosrivera avatar enesasillioglu avatar raimartinsb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

chatwoot-sdk's Issues

Chatwoot 3.0 errors with Evolution-API

Hi, using latest release inside Evolution-API, and I get: with latest chatwoot 3.0

 [Evolution API]  v1.5.0  1   -  Sat Sep 16 2023 08:23:34     ERROR   [unhandledRejection]  [object]   
2023-09-16T11:23:34.873574788Z {
2023-09-16T11:23:34.873598099Z   origin: Promise {
2023-09-16T11:23:34.873602702Z     <rejected> ApiError: Internal Server Error
2023-09-16T11:23:34.873606602Z         at catchErrorCodes (/evolution/node_modules/@figuro/chatwoot-sdk/dist/core/request.js:226:15)
2023-09-16T11:23:34.873610233Z         at /evolution/node_modules/@figuro/chatwoot-sdk/dist/core/request.js:257:17
2023-09-16T11:23:34.873614015Z         at processTicksAndRejections (node:internal/process/task_queues:96:5) {
2023-09-16T11:23:34.873617544Z       url: 'https://chat-web.uhl.cloud/api/v1/accounts/2/conversations',
2023-09-16T11:23:34.873621435Z       status: 500,
2023-09-16T11:23:34.873636555Z       statusText: 'Internal Server Error',
2023-09-16T11:23:34.873640867Z       body: [Object],
2023-09-16T11:23:34.873643956Z       request: [Object]
2023-09-16T11:23:34.873646978Z     }
2023-09-16T11:23:34.873649973Z   },
2023-09-16T11:23:34.873653046Z   stderr: 2,
2023-09-16T11:23:34.873656216Z   error: ApiError: Internal Server Error
2023-09-16T11:23:34.873659336Z       at catchErrorCodes (/evolution/node_modules/@figuro/chatwoot-sdk/dist/core/request.js:226:15)
2023-09-16T11:23:34.873662658Z       at /evolution/node_modules/@figuro/chatwoot-sdk/dist/core/request.js:257:17
2023-09-16T11:23:34.873665981Z       at processTicksAndRejections (node:internal/process/task_queues:96:5) {
2023-09-16T11:23:34.873669662Z     url: 'https://chat-web.uhl.cloud/api/v1/accounts/2/conversations',
2023-09-16T11:23:34.873673016Z     status: 500,
2023-09-16T11:23:34.873676797Z     statusText: 'Internal Server Error',
2023-09-16T11:23:34.873680615Z     body: { status: 500, error: 'Internal Server Error' },
2023-09-16T11:23:34.873683693Z     request: {
2023-09-16T11:23:34.873686762Z       method: 'POST',
2023-09-16T11:23:34.873689767Z       url: '/api/v1/accounts/{account_id}/conversations',
2023-09-16T11:23:34.873692721Z       path: [Object],
2023-09-16T11:23:34.873695791Z       body: [Object],
2023-09-16T11:23:34.873698800Z       errors: [Object]
2023-09-16T11:23:34.873701869Z     }
2023-09-16T11:23:34.873705055Z   }
2023-09-16T11:23:34.873708150Z } 
2023-09-16T11:23:34.873711288Z 
2023-09-16T11:24:29.819266225Z [Evolution API]  v1.5.0  1   -  Sat Sep 16 2023 08:24:29     

linked to: EvolutionAPI/evolution-api#114

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.