Code Monkey home page Code Monkey logo

woot's Introduction

woot

Woot is a simple Chatwoot API wrapper for Python. It provides an easy-to-use interface for interacting with the Chatwoot API, allowing you to perform various actions such as creating, retrieving, updating, and deleting conversations, messages, and more.

Also, if you wonder how to use it for Chatwoot webhook have a look at woothook

Installation

To install Woot, simply run:

pip install git+https://github.com/dearkafka/woot

Usage

To use Woot, you'll first need to import the Chatwoot or AsyncChatwoot class from the woot:

from woot import Chatwoot, AsyncChatwoot

Next, create an instance of Chatwoot or AsyncChatwoot by passing your Chatwoot URL and access key:

chatwoot = Chatwoot(chatwoot_url="https://your-chatwoot-instance.com", access_key="your-access-key")

Or, for the async version:

async_chatwoot = AsyncChatwoot(chatwoot_url="https://your-chatwoot-instance.com", access_key="your-access-key")

You can then access the various resources and perform actions on them as attributes of the Chatwoot or AsyncChatwoot instance.

Example1

You can also see details about specific methods, but remember woot takes keyword arguments only, no positional allowed

Example2

Resources

Woot provides access to various Chatwoot resources, such as:

  • Conversations
  • Messages
  • Contacts
  • Labels
  • Teams
  • Agents
  • And more

To access a resource, use the appropriate attribute of the Chatwoot or AsyncChatwoot instance:

conversations = chatwoot.conversations

Each resource has a set of actions that can be performed, such as list, create, update, and delete. To perform an action, simply call the corresponding method on the resource:

all_conversations = conversations.list(account_id=1)

API Documentation

To view the available actions and their corresponding API endpoints for each resource, simply print the Chatwoot or AsyncChatwoot instance:

print(chatwoot)

This will display a list of available actions, their HTTP methods, and API endpoints.

Example

Here's an example demonstrating how to use Woot to list all conversations:

from woot import Chatwoot

chatwoot_url = "https://your-chatwoot-instance.com"
access_key = "your-access-key"

chatwoot = Chatwoot(chatwoot_url=chatwoot_url, access_key=access_key)

conversations = chatwoot.conversations
all_conversations = conversations.list(account_id=1)

print(all_conversations)

Project is influenced by and borrowed from simple_rest_client and in fact started by using it as it is, but then I decided to make it more Chatwoot specific and add some features that I needed.

License

The project is licensed under the Cooperative Non-Violent Public License v7 or later (CNPLv7+) - see the LICENSE for details. Built for people, not corporations.

woot's People

Contributors

dearkafka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

rudcode vidz1979

woot's Issues

ValueError: mutable default <class 'woot.actions.Action'> for field create is not allowed: use default_factory

I am getting this error:

Traceback (most recent call last):
  File "/home/junior/.local/bin/woothook", line 5, in <module>
    from woothook.service import app
  File "/home/junior/.local/lib/python3.11/site-packages/woothook/service.py", line 4, in <module>
    from woot import AsyncChatwoot
  File "/home/junior/.local/lib/python3.11/site-packages/woot/__init__.py", line 1, in <module>
    from woot.api import Chatwoot, AsyncChatwoot
  File "/home/junior/.local/lib/python3.11/site-packages/woot/api.py", line 6, in <module>
    import woot.resources as wr
  File "/home/junior/.local/lib/python3.11/site-packages/woot/resources.py", line 22, in <module>
    import woot.actions as a
  File "/home/junior/.local/lib/python3.11/site-packages/woot/actions.py", line 23, in <module>
    @dataclass
     ^^^^^^^^^
  File "pydantic/dataclasses.py", line 231, in pydantic.dataclasses.dataclass
    repr_running = set()
  File "pydantic/dataclasses.py", line 207, in pydantic.dataclasses.dataclass.wrap
    _FIELD_INITVAR = _FIELD_BASE('_FIELD_INITVAR')
  File "/usr/lib/python3.11/dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/usr/lib/python3.11/dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'woot.actions.Action'> for field create is not allowed: use default_factory
$ pip freeze
anyio==4.2.0
certifi==2024.2.2
h11==0.14.0
httpcore==1.0.2
httpx==0.26.0
idna==3.6
pydantic==1.10.13
python-slugify==8.0.4
python-status==1.0.1
sniffio==1.3.0
text-unidecode==1.3
typing_extensions==4.9.0
woot @ git+https://github.com/dearkafka/woot@6a0b777344a2cdccab3fdfc380b5d974d4607f3f

$ python --version
Python 3.11.4

Ticketing System In Django

Please give me an Idea of how I can utilize this wrapper to build a ticketing system for my users in python Django

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.