Stax.ai CX Automation SDK
Project description
Stax.ai CX Automation SDK
This project is created and maintained by Stax.ai, Inc.. This is proprietary to Stax.ai, Inc. Unauthorized use, copy, license, or modification of this project and all associated source code is strictly prohibited.
About
...coming soon...
Installation
pip install stax_cx_automation_sdk
Usage
Create a Stax.ai automation
Do this by creating a database entry manually that matches the schema for Automation.
Write your automation app
import os
from stax_cx_automation_sdk import def_automation
# This is the `_id` of the automation from the DB and the token user for cross-internal system communication
@def_automation(os.getenv('AUTOMATION_ID'), os.getenv('INTERNAL_KEY'))
def app(team:str, task:str, project:str, config:list[dict]):
'''
Your custom automation app. Is provided the following arguments:
- team [str]: Team ID string
- task [str]: Task ID string
- project [str]: Project ID string
- config [list[dict]]: Pipeline configuration for automation
Return the following arguments:
- status [str]: One of Success, Error, Active
- message [str]: Human-readable message to go with the status
If there is an error, raise an exception with a nice human-readable error message to show up on the log.
'''
# Put your automation functionality here
# ...
# Raise an exception to stop the pipeline and flag the task
raise Exception("Oops, something went wrong!")
# The return
return "Success", "The required action has been completed" # Replace this with something more relevant, for example: 'Email sent to: naru@stax.ai'
Using the Stax.ai API
A pre-authenticated instance of the Stax.ai API is available to be used. See example below:
from stax_cx_automation_sdk import api
res = api.get("/todo/project/66906152e0f1a56abd992a60")
res = api.post("/todo/project/_list", {
"search": "foo"
})
res = api.patch("/todo/project/66906152e0f1a56abd992a60", {
"tags": [ "Test" ]
})
res = api.delete("/todo/project/66906152e0f1a56abd992a60")
These calls are made with the team ID, automation header and key for authorization.
Testing your automation
To test your automation, simply comment out the @def_automation line and call the app function with the appropriate input arguments.
Deploy your automation
- Navigate to the
Project CXGoogle Cloud topic. - Create a Pub/Sub topic with the name:
auto-{NAME}, for exampleauto-send-email. - Create a Cloud Function with the same name as the Pub/Sub topic.
- Set the trigger type to
Cloud Pub/Sub. - Pick the previously created Pub/Sub topic.
- Select the appropriate memory, CPU, timeout, and concurrency settings.
- Select the
App Engine default service account. - Add the runtime environment variable:
AUTOMATION_IDandINTERNAL_KEY. - Ensure your entry file is called
main.pyand that you have arequirements.txtfile with your dependencies. - Load your source code as a ZIP and configure the function appropriately (make sure the entry-point is set.)
- Test your function, and deploy it!
- Set the
urlproperty in the automation to your Pub/Sub topic name.
Developers
Building this SDK
[For Stax.ai, Inc. developers only]
- Increment the minor/major version in
setup.py. python3 -m pip install --upgrade buildpython3 -m buildpython3 -m pip install --upgrade twinepython3 -m twine upload dist/*- Request the PyPi API token from Naru if you don't have it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stax_cx_automation_sdk-0.1.11.tar.gz.
File metadata
- Download URL: stax_cx_automation_sdk-0.1.11.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e640024fdb1b3ca2eeb952679b3ede3e3aef76a6ccd06a726b2ec7a034544968
|
|
| MD5 |
a95d8df656b883dc6d5afc672dd9504f
|
|
| BLAKE2b-256 |
a2be5f77f765ea4ea11ffbe38e8f44ddf6b1ed5de86902e3d1ab5e3e0e71f253
|
File details
Details for the file stax_cx_automation_sdk-0.1.11-py3-none-any.whl.
File metadata
- Download URL: stax_cx_automation_sdk-0.1.11-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
800acde8c3283100cef64d325dec46d800bb8231a63015b34e3f9846f0ec59cc
|
|
| MD5 |
e00e2a496b8836bebdb8cf6d633a422f
|
|
| BLAKE2b-256 |
63d21070adb01b9f6e6871916d2a0f088dc88f5e1d0db8f5cab2746de5b8d6a2
|