callaider 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- callaider-0.1.0/.gitignore +219 -0
- callaider-0.1.0/LICENSE +21 -0
- callaider-0.1.0/PKG-INFO +144 -0
- callaider-0.1.0/README.md +128 -0
- callaider-0.1.0/examples/test_mock.py +58 -0
- callaider-0.1.0/pyproject.toml +28 -0
- callaider-0.1.0/src/callaider/__init__.py +27 -0
- callaider-0.1.0/src/callaider/_base_client.py +216 -0
- callaider-0.1.0/src/callaider/_client.py +99 -0
- callaider-0.1.0/src/callaider/_constants.py +4 -0
- callaider-0.1.0/src/callaider/_models.py +140 -0
- callaider-0.1.0/src/callaider/_streaming.py +117 -0
- callaider-0.1.0/src/callaider/exceptions.py +55 -0
- callaider-0.1.0/src/callaider/resources/__init__.py +0 -0
- callaider-0.1.0/src/callaider/resources/assistants.py +96 -0
- callaider-0.1.0/src/callaider/resources/ringing.py +171 -0
- callaider-0.1.0/src/callaider/webhooks.py +40 -0
- callaider-0.1.0/tests/__init__.py +0 -0
- callaider-0.1.0/tests/conftest.py +17 -0
- callaider-0.1.0/tests/test_assistants.py +0 -0
- callaider-0.1.0/tests/test_errors.py +46 -0
- callaider-0.1.0/tests/test_health.py +29 -0
- callaider-0.1.0/tests/test_ringing.py +40 -0
- callaider-0.1.0/tests/test_webhooks.py +30 -0
- callaider-0.1.0/uv.lock +470 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
.idea/
|
|
190
|
+
*.iml
|
|
191
|
+
|
|
192
|
+
# Abstra
|
|
193
|
+
# Abstra is an AI-powered process automation framework.
|
|
194
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
195
|
+
# Learn more at https://abstra.io/docs
|
|
196
|
+
.abstra/
|
|
197
|
+
|
|
198
|
+
# Visual Studio Code
|
|
199
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
200
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
201
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
202
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
203
|
+
# .vscode/
|
|
204
|
+
# Temporary file for partial code execution
|
|
205
|
+
tempCodeRunnerFile.py
|
|
206
|
+
|
|
207
|
+
# Ruff stuff:
|
|
208
|
+
.ruff_cache/
|
|
209
|
+
|
|
210
|
+
# PyPI configuration file
|
|
211
|
+
.pypirc
|
|
212
|
+
|
|
213
|
+
# Marimo
|
|
214
|
+
marimo/_static/
|
|
215
|
+
marimo/_lsp/
|
|
216
|
+
__marimo__/
|
|
217
|
+
|
|
218
|
+
# Streamlit
|
|
219
|
+
.streamlit/secrets.toml
|
callaider-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gleb
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
callaider-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: callaider
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for Callaider AI Voice Platform
|
|
5
|
+
Project-URL: Homepage, https://github.com/astatdeglebantiy/callaider-sdk-python
|
|
6
|
+
Author-email: AstatdeGlebantiy <glebsh2chko@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Requires-Dist: httpx2>=2.12.0
|
|
11
|
+
Requires-Dist: pydantic>=2.0.0
|
|
12
|
+
Requires-Dist: pytest-asyncio>=0.23.0
|
|
13
|
+
Requires-Dist: pytest>=8.0.0
|
|
14
|
+
Requires-Dist: respx>=0.21.0
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# Callaider Python SDK
|
|
18
|
+
|
|
19
|
+
[](https://pypi.org/project/callaider/)
|
|
20
|
+
[](https://pypi.org/project/callaider/)
|
|
21
|
+
[](https://opensource.org/licenses/MIT)
|
|
22
|
+
|
|
23
|
+
The official Python client library for the [Callaider](https://callaider.ai) AI voice calling and conversational platform.
|
|
24
|
+
|
|
25
|
+
Built on top of the [Callaider OpenAPI 3.0.3 specification](https://github.com/NBM-Labs/callaider_openapi).
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- ⚡ **Sync & Async clients** built on modern `httpx`.
|
|
32
|
+
- 🛡️ **Fully typed** request/response models with Pydantic v2.
|
|
33
|
+
- 🔄 **Automatic retries** with exponential backoff on 429/5xx errors.
|
|
34
|
+
- 📞 **Complete Ringing API support**: Campaigns, batch calls, recordings, and statistics.
|
|
35
|
+
- 🤖 **External Conversation Bridge**: Direct AI assistant messaging integration (ideal for Telegram bots).
|
|
36
|
+
- 🪝 **Built-in Webhooks parser**: Typed events parsing for callback handling.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install callaider
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Or using `uv`:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
uv add callaider
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Quickstart
|
|
55
|
+
|
|
56
|
+
### Synchronous Usage
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from callaider import Callaider
|
|
60
|
+
|
|
61
|
+
client = Callaider(api_key="your_api_key_here")
|
|
62
|
+
|
|
63
|
+
# 1. Check API status
|
|
64
|
+
health = client.health()
|
|
65
|
+
print(f"API status: {health.status}")
|
|
66
|
+
|
|
67
|
+
# 2. Create an automated call campaign
|
|
68
|
+
campaign = client.ringing.create_campaign(
|
|
69
|
+
assistant_id="asst_sales_01",
|
|
70
|
+
recipients=[
|
|
71
|
+
{"phone": "+380501234567", "name": "Alex"}
|
|
72
|
+
],
|
|
73
|
+
name="VIP Outreach Campaign"
|
|
74
|
+
)
|
|
75
|
+
print(f"Created campaign #{campaign.id} with status: {campaign.status}")
|
|
76
|
+
|
|
77
|
+
# 3. Launch the campaign
|
|
78
|
+
client.ringing.launch_campaign(campaign.id)
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Asynchronous Usage (FastAPI, Asyncio, Telegram Bots)
|
|
82
|
+
|
|
83
|
+
```python
|
|
84
|
+
import asyncio
|
|
85
|
+
from callaider import AsyncCallaider
|
|
86
|
+
|
|
87
|
+
async def main():
|
|
88
|
+
async with AsyncCallaider(api_key="your_api_key_here") as client:
|
|
89
|
+
# Send a message to AI assistant bridge
|
|
90
|
+
response = await client.assistants.send_message(
|
|
91
|
+
assistant_id="asst_support_01",
|
|
92
|
+
external_conversation_id="telegram_user_12345",
|
|
93
|
+
message="Hello! I need help with my order."
|
|
94
|
+
)
|
|
95
|
+
print("AI Response:", response.text)
|
|
96
|
+
|
|
97
|
+
asyncio.run(main())
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Webhooks Handling
|
|
103
|
+
|
|
104
|
+
Easily parse incoming Callaider webhook payloads in FastAPI or Flask:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from fastapi import FastAPI, Request
|
|
108
|
+
from callaider import Webhooks
|
|
109
|
+
|
|
110
|
+
app = FastAPI()
|
|
111
|
+
|
|
112
|
+
@app.post("/webhooks/callaider")
|
|
113
|
+
async def handle_webhook(request: Request):
|
|
114
|
+
payload = await request.body()
|
|
115
|
+
event = Webhooks.construct_event(payload)
|
|
116
|
+
|
|
117
|
+
if event.event == "call.completed":
|
|
118
|
+
print(f"Call {event.data.call_id} finished. Duration: {event.data.duration_seconds}s")
|
|
119
|
+
print(f"Audio recording: {event.data.recording_url}")
|
|
120
|
+
|
|
121
|
+
return {"status": "ok"}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Development & Testing
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Clone the repository
|
|
130
|
+
git clone https://github.com/astatdeglebantiy/callaider-python.git
|
|
131
|
+
cd callaider-python
|
|
132
|
+
|
|
133
|
+
# Install dependencies with uv
|
|
134
|
+
uv sync --all-extras
|
|
135
|
+
|
|
136
|
+
# Run unit tests
|
|
137
|
+
uv run pytest
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Callaider Python SDK
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/callaider/)
|
|
4
|
+
[](https://pypi.org/project/callaider/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
The official Python client library for the [Callaider](https://callaider.ai) AI voice calling and conversational platform.
|
|
8
|
+
|
|
9
|
+
Built on top of the [Callaider OpenAPI 3.0.3 specification](https://github.com/NBM-Labs/callaider_openapi).
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- ⚡ **Sync & Async clients** built on modern `httpx`.
|
|
16
|
+
- 🛡️ **Fully typed** request/response models with Pydantic v2.
|
|
17
|
+
- 🔄 **Automatic retries** with exponential backoff on 429/5xx errors.
|
|
18
|
+
- 📞 **Complete Ringing API support**: Campaigns, batch calls, recordings, and statistics.
|
|
19
|
+
- 🤖 **External Conversation Bridge**: Direct AI assistant messaging integration (ideal for Telegram bots).
|
|
20
|
+
- 🪝 **Built-in Webhooks parser**: Typed events parsing for callback handling.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install callaider
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Or using `uv`:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
uv add callaider
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Quickstart
|
|
39
|
+
|
|
40
|
+
### Synchronous Usage
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from callaider import Callaider
|
|
44
|
+
|
|
45
|
+
client = Callaider(api_key="your_api_key_here")
|
|
46
|
+
|
|
47
|
+
# 1. Check API status
|
|
48
|
+
health = client.health()
|
|
49
|
+
print(f"API status: {health.status}")
|
|
50
|
+
|
|
51
|
+
# 2. Create an automated call campaign
|
|
52
|
+
campaign = client.ringing.create_campaign(
|
|
53
|
+
assistant_id="asst_sales_01",
|
|
54
|
+
recipients=[
|
|
55
|
+
{"phone": "+380501234567", "name": "Alex"}
|
|
56
|
+
],
|
|
57
|
+
name="VIP Outreach Campaign"
|
|
58
|
+
)
|
|
59
|
+
print(f"Created campaign #{campaign.id} with status: {campaign.status}")
|
|
60
|
+
|
|
61
|
+
# 3. Launch the campaign
|
|
62
|
+
client.ringing.launch_campaign(campaign.id)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Asynchronous Usage (FastAPI, Asyncio, Telegram Bots)
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
import asyncio
|
|
69
|
+
from callaider import AsyncCallaider
|
|
70
|
+
|
|
71
|
+
async def main():
|
|
72
|
+
async with AsyncCallaider(api_key="your_api_key_here") as client:
|
|
73
|
+
# Send a message to AI assistant bridge
|
|
74
|
+
response = await client.assistants.send_message(
|
|
75
|
+
assistant_id="asst_support_01",
|
|
76
|
+
external_conversation_id="telegram_user_12345",
|
|
77
|
+
message="Hello! I need help with my order."
|
|
78
|
+
)
|
|
79
|
+
print("AI Response:", response.text)
|
|
80
|
+
|
|
81
|
+
asyncio.run(main())
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Webhooks Handling
|
|
87
|
+
|
|
88
|
+
Easily parse incoming Callaider webhook payloads in FastAPI or Flask:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from fastapi import FastAPI, Request
|
|
92
|
+
from callaider import Webhooks
|
|
93
|
+
|
|
94
|
+
app = FastAPI()
|
|
95
|
+
|
|
96
|
+
@app.post("/webhooks/callaider")
|
|
97
|
+
async def handle_webhook(request: Request):
|
|
98
|
+
payload = await request.body()
|
|
99
|
+
event = Webhooks.construct_event(payload)
|
|
100
|
+
|
|
101
|
+
if event.event == "call.completed":
|
|
102
|
+
print(f"Call {event.data.call_id} finished. Duration: {event.data.duration_seconds}s")
|
|
103
|
+
print(f"Audio recording: {event.data.recording_url}")
|
|
104
|
+
|
|
105
|
+
return {"status": "ok"}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Development & Testing
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Clone the repository
|
|
114
|
+
git clone https://github.com/astatdeglebantiy/callaider-python.git
|
|
115
|
+
cd callaider-python
|
|
116
|
+
|
|
117
|
+
# Install dependencies with uv
|
|
118
|
+
uv sync --all-extras
|
|
119
|
+
|
|
120
|
+
# Run unit tests
|
|
121
|
+
uv run pytest
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from callaider import AsyncCallaider, Callaider, Webhooks
|
|
3
|
+
|
|
4
|
+
MOCK_SERVER_URL = "http://127.0.0.1:4010"
|
|
5
|
+
API_KEY = "test_token"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_sync():
|
|
9
|
+
print("=== Testing Sync Client ===")
|
|
10
|
+
client = Callaider(api_key=API_KEY, base_url=MOCK_SERVER_URL)
|
|
11
|
+
|
|
12
|
+
# 1. Health
|
|
13
|
+
health = client.health()
|
|
14
|
+
print("Health:", health.status)
|
|
15
|
+
|
|
16
|
+
# 2. Campaigns
|
|
17
|
+
campaigns = client.ringing.list_campaigns()
|
|
18
|
+
print("Campaigns count:", len(campaigns))
|
|
19
|
+
|
|
20
|
+
# 3. Assistants message
|
|
21
|
+
assistant_reply = client.assistants.send_message(
|
|
22
|
+
assistant_id=1,
|
|
23
|
+
external_conversation_id="telegram_chat_987654",
|
|
24
|
+
message="Hello AI, this is a test message!",
|
|
25
|
+
)
|
|
26
|
+
print("Assistant Full Response:", assistant_reply)
|
|
27
|
+
print("Assistant Text Reply:", assistant_reply.text)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
async def test_async():
|
|
31
|
+
print("\n=== Testing Async Client ===")
|
|
32
|
+
async with AsyncCallaider(api_key=API_KEY, base_url=MOCK_SERVER_URL) as client:
|
|
33
|
+
health = await client.health()
|
|
34
|
+
print("Async Health:", health.status)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_webhooks():
|
|
38
|
+
print("\n=== Testing Webhooks Parser ===")
|
|
39
|
+
raw_payload = """
|
|
40
|
+
{
|
|
41
|
+
"event": "call.completed",
|
|
42
|
+
"timestamp": "2026-09-04T12:00:00Z",
|
|
43
|
+
"data": {
|
|
44
|
+
"call_id": 12345,
|
|
45
|
+
"phone": "+380501234567",
|
|
46
|
+
"duration_seconds": 45,
|
|
47
|
+
"recording_url": "https://storage.callaider.ai/recordings/12345.mp3"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
"""
|
|
51
|
+
event = Webhooks.construct_event(raw_payload)
|
|
52
|
+
print(f"Parsed Event: {event.event} for call #{event.data.call_id}")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if __name__ == "__main__":
|
|
56
|
+
test_sync()
|
|
57
|
+
asyncio.run(test_async())
|
|
58
|
+
test_webhooks()
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "callaider"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for Callaider AI Voice Platform"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "AstatdeGlebantiy", email = "glebsh2chko@gmail.com" }
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"httpx2>=2.12.0",
|
|
17
|
+
"pydantic>=2.0.0",
|
|
18
|
+
"pytest>=8.0.0",
|
|
19
|
+
"pytest-asyncio>=0.23.0",
|
|
20
|
+
"respx>=0.21.0",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/astatdeglebantiy/callaider-sdk-python"
|
|
25
|
+
|
|
26
|
+
[tool.pytest.ini_options]
|
|
27
|
+
testpaths = ["tests"]
|
|
28
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
from callaider._client import AsyncCallaider, Callaider
|
|
2
|
+
from callaider.exceptions import (
|
|
3
|
+
APIConnectionError,
|
|
4
|
+
APIError,
|
|
5
|
+
APIStatusError,
|
|
6
|
+
AuthenticationError,
|
|
7
|
+
CallaiderError,
|
|
8
|
+
InternalServerError,
|
|
9
|
+
NotFoundError,
|
|
10
|
+
RateLimitError,
|
|
11
|
+
)
|
|
12
|
+
from callaider.webhooks import WebhookParsingError, Webhooks
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"Callaider",
|
|
16
|
+
"AsyncCallaider",
|
|
17
|
+
"Webhooks",
|
|
18
|
+
"WebhookParsingError",
|
|
19
|
+
"CallaiderError",
|
|
20
|
+
"APIError",
|
|
21
|
+
"APIStatusError",
|
|
22
|
+
"AuthenticationError",
|
|
23
|
+
"NotFoundError",
|
|
24
|
+
"RateLimitError",
|
|
25
|
+
"InternalServerError",
|
|
26
|
+
"APIConnectionError",
|
|
27
|
+
]
|