stax-cx-automation-sdk


Namestax-cx-automation-sdk JSON
Version 0.1.9 PyPI version JSON
download
home_pagehttps://bitbucket.org/staxai/cx-automation-sdk
SummaryStax.ai CX Automation SDK
upload_time2024-11-05 05:54:43
maintainerNone
docs_urlNone
authorStax.ai, Inc. <https://stax.ai>
requires_python>=3.6
licenseProprietary
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Stax.ai CX Automation SDK

This project is created and maintained by [Stax.ai, Inc.](https://stax.ai). 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

```sh
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

```py
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:

```py
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

1. Navigate to the `Project CX` Google Cloud topic.
2. Create a Pub/Sub topic with the name: `auto-{NAME}`, for example `auto-send-email`.
3. Create a Cloud Function with the same name as the Pub/Sub topic.
4. Set the trigger type to `Cloud Pub/Sub`.
5. Pick the previously created Pub/Sub topic.
6. Select the appropriate memory, CPU, timeout, and concurrency settings.
7. Select the `App Engine default service account`.
8. Add the runtime environment variable: `AUTOMATION_ID` and `INTERNAL_KEY`.
9. Ensure your entry file is called `main.py` and that you have a `requirements.txt` file with your dependencies.
10. Load your source code as a ZIP and configure the function appropriately (make sure the entry-point is set.)
11. Test your function, and deploy it!
12. Set the `url` property in the automation to your Pub/Sub topic name.

## Developers

### Building this SDK

[For Stax.ai, Inc. developers only]

1. Increment the minor/major version in `setup.py`.
2. `python3 -m pip install --upgrade build`
3. `python3 -m build`
4. `python3 -m pip install --upgrade twine`
5. `python3 -m twine upload dist/*`
6. Request the PyPi API token from Naru if you don't have it.

            

Raw data

            {
    "_id": null,
    "home_page": "https://bitbucket.org/staxai/cx-automation-sdk",
    "name": "stax-cx-automation-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": "Stax.ai, Inc. <https://stax.ai>",
    "author_email": "naru@stax.ai",
    "download_url": "https://files.pythonhosted.org/packages/79/95/37d70ca79737e761b1886dbd6a04c5b10ac4d17677a1357faabb8fb44f0e/stax_cx_automation_sdk-0.1.9.tar.gz",
    "platform": null,
    "description": "# Stax.ai CX Automation SDK\r\n\r\nThis project is created and maintained by [Stax.ai, Inc.](https://stax.ai). This is proprietary to Stax.ai, Inc. Unauthorized use, copy, license, or modification of this project and all associated source code is strictly prohibited.\r\n\r\n## About\r\n\r\n...coming soon...\r\n\r\n## Installation\r\n\r\n```sh\r\npip install stax_cx_automation_sdk\r\n```\r\n\r\n## Usage\r\n\r\n### Create a Stax.ai automation\r\n\r\nDo this by creating a database entry manually that matches the schema for `Automation`.\r\n\r\n### Write your automation app\r\n\r\n```py\r\nimport os\r\nfrom stax_cx_automation_sdk import def_automation\r\n\r\n# This is the `_id` of the automation from the DB and the token user for cross-internal system communication\r\n@def_automation(os.getenv('AUTOMATION_ID'), os.getenv('INTERNAL_KEY'))\r\ndef app(team:str, task:str, project:str, config:list[dict]):\r\n    '''\r\n    Your custom automation app. Is provided the following arguments:\r\n    - team [str]: Team ID string\r\n    - task [str]: Task ID string\r\n    - project [str]: Project ID string\r\n    - config [list[dict]]: Pipeline configuration for automation\r\n\r\n    Return the following arguments:\r\n    - status [str]: One of Success, Error, Active\r\n    - message [str]: Human-readable message to go with the status\r\n    If there is an error, raise an exception with a nice human-readable error message to show up on the log.\r\n    '''\r\n\r\n    # Put your automation functionality here\r\n    # ...\r\n\r\n    # Raise an exception to stop the pipeline and flag the task\r\n    raise Exception(\"Oops, something went wrong!\")\r\n\r\n    # The return \r\n    return \"Success\", \"The required action has been completed\" # Replace this with something more relevant, for example: 'Email sent to: naru@stax.ai'\r\n```\r\n\r\n### Using the Stax.ai API\r\n\r\nA pre-authenticated instance of the Stax.ai API is available to be used. See example below:\r\n\r\n```py\r\nfrom stax_cx_automation_sdk import api\r\n\r\nres = api.get(\"/todo/project/66906152e0f1a56abd992a60\")\r\n\r\nres = api.post(\"/todo/project/_list\", {\r\n    \"search\": \"foo\"\r\n})\r\n\r\nres = api.patch(\"/todo/project/66906152e0f1a56abd992a60\", {\r\n    \"tags\": [ \"Test\" ]\r\n})\r\n\r\nres = api.delete(\"/todo/project/66906152e0f1a56abd992a60\")\r\n```\r\n\r\nThese calls are made with the team ID, automation header and key for authorization.\r\n\r\n### Testing your automation\r\n\r\nTo test your automation, simply comment out the `@def_automation` line and call the `app` function with the appropriate input arguments.\r\n\r\n### Deploy your automation\r\n\r\n1. Navigate to the `Project CX` Google Cloud topic.\r\n2. Create a Pub/Sub topic with the name: `auto-{NAME}`, for example `auto-send-email`.\r\n3. Create a Cloud Function with the same name as the Pub/Sub topic.\r\n4. Set the trigger type to `Cloud Pub/Sub`.\r\n5. Pick the previously created Pub/Sub topic.\r\n6. Select the appropriate memory, CPU, timeout, and concurrency settings.\r\n7. Select the `App Engine default service account`.\r\n8. Add the runtime environment variable: `AUTOMATION_ID` and `INTERNAL_KEY`.\r\n9. Ensure your entry file is called `main.py` and that you have a `requirements.txt` file with your dependencies.\r\n10. Load your source code as a ZIP and configure the function appropriately (make sure the entry-point is set.)\r\n11. Test your function, and deploy it!\r\n12. Set the `url` property in the automation to your Pub/Sub topic name.\r\n\r\n## Developers\r\n\r\n### Building this SDK\r\n\r\n[For Stax.ai, Inc. developers only]\r\n\r\n1. Increment the minor/major version in `setup.py`.\r\n2. `python3 -m pip install --upgrade build`\r\n3. `python3 -m build`\r\n4. `python3 -m pip install --upgrade twine`\r\n5. `python3 -m twine upload dist/*`\r\n6. Request the PyPi API token from Naru if you don't have it.\r\n",
    "bugtrack_url": null,
    "license": "Proprietary",
    "summary": "Stax.ai CX Automation SDK",
    "version": "0.1.9",
    "project_urls": {
        "Homepage": "https://bitbucket.org/staxai/cx-automation-sdk"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "81bca483ca5946b63ce593115209a5b019064af231bdb4e234aeed260903c1ac",
                "md5": "bccf193fe9d5ed13949950fc16a9a071",
                "sha256": "fb5bcef4ce0d03c6bb252f58c0ae44f5b4aaf6db2c36bb128736382e88501c43"
            },
            "downloads": -1,
            "filename": "stax_cx_automation_sdk-0.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bccf193fe9d5ed13949950fc16a9a071",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 14190,
            "upload_time": "2024-11-05T05:54:41",
            "upload_time_iso_8601": "2024-11-05T05:54:41.875271Z",
            "url": "https://files.pythonhosted.org/packages/81/bc/a483ca5946b63ce593115209a5b019064af231bdb4e234aeed260903c1ac/stax_cx_automation_sdk-0.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "799537d70ca79737e761b1886dbd6a04c5b10ac4d17677a1357faabb8fb44f0e",
                "md5": "e190d74ef1cc59b1eef14dfe270418a9",
                "sha256": "7dec0ba32e6a978903506d593c2574ef1f061a9ec1bb44e01482d1038f535aab"
            },
            "downloads": -1,
            "filename": "stax_cx_automation_sdk-0.1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "e190d74ef1cc59b1eef14dfe270418a9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12887,
            "upload_time": "2024-11-05T05:54:43",
            "upload_time_iso_8601": "2024-11-05T05:54:43.163906Z",
            "url": "https://files.pythonhosted.org/packages/79/95/37d70ca79737e761b1886dbd6a04c5b10ac4d17677a1357faabb8fb44f0e/stax_cx_automation_sdk-0.1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-05 05:54:43",
    "github": false,
    "gitlab": false,
    "bitbucket": true,
    "codeberg": false,
    "bitbucket_user": "staxai",
    "bitbucket_project": "cx-automation-sdk",
    "lcname": "stax-cx-automation-sdk"
}
        
Elapsed time: 0.43637s