sarufi


Namesarufi JSON
Version 0.1.9 PyPI version JSON
download
home_pagehttps://github.com/Neurotech-HQ/sarufi-python-sdk
SummaryOpensource python wrapper to Sarufi Conversation API
upload_time2024-04-05 16:44:53
maintainerNone
docs_urlNone
authorJordan Kalebu
requires_python>=3.6
licenseMIT
keywords sarufi sarufi python sdk conversation api python swahili conversational api conversational platform python
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <samp>

# sarufi-python-sdk

Sarufi Python SDK to help you interact with SARUFI platform

## Installation

Make sure you have [sarufi package](https://github.com/Neurotech-HQ/sarufi-python-sdk) installed on your machine before launching your telegram bot, you can easily install by the following command;

```bash
git clone https://github.com/Neurotech-HQ/sarufi-python-sdk
cd sarufi-python-sdk
sarufi-python-sdk $ python setup.py install
```

## Authentication

To authenticate you're bot, you have to specify your client_id and password for Sarufi Platform just as shown below;

```python
>>> from sarufi import Sarufi
>>> sarufi = Sarufi(api_key='your API KEY')
```

## Creating a Bot

To create you're bot with sarufi, you have to be aware of two importants idea or concepts which is **intents** and **flow**.

Here an example on how to create your bot;

```python
sarufi.create_bot(
    name="Athony bot",
    description="My bot can do a lot",
    intents={
        "salamu": ["Mambo", "Hi", "Hello", "Niaje"],
        "contact": [
            "naomba mawasiliano",
            "naomba number",
            "naomba namba",
            "nipe mawasiliano",
            "nipe contact",
        ],
    },
    flow={
        "salamu": {"message": ["Hi", "Naimani upo salama"], "next": "end"},
        "contact": {
            "message": ["Ungependa kupata namba ya nani ?"],
            "next_state": "chukua_namba",
        },
        "chukua_namba": {
            "message": ["Namba ya huyo mtu ni 07374734737", "Karibu tena !!"],
            "next_state": "end",
        },
    },
)
```

### Creating a Bot from file

You can create your bot from a file, Here is an example on how to create your bot from a file;

```python
from sarufi import Sarufi

sarufi = Sarufi(api_key='your API KEY')


if __name__ == "__main__":
    response = sarufi.create_from_file(
        intents="data/intents.yaml",
        flow="data/flows.yaml",
        metadata="data/metadata.yaml",
    )
    print(response.data)
```

## Updating bot

Updating the bot is comparatively similar to creating a bot but this time you have to explicity specify the **project ID** of your bot.

```python
sarufi.update_bot(
    name="Athony bot",
    description="My bot can do a lot",
    intents={
        "salamu": ["Mambo", "Hi", "Hello", "Niaje"],
        "contact": [
            "naomba mawasiliano",
            "naomba number",
            "naomba namba",
            "nipe mawasiliano",
            "nipe contact",
        ],
    },
    flow={
        "salamu": {"message": ["Hi", "Naimani upo salama"], "next": "end"},
        "contact": {
            "message": ["Ungependa kupata namba ya nani ?"],
            "next_state": "chukua_namba",
        },
        "chukua_namba": {
            "message": ["Namba ya huyo mtu ni 07374734737", "Karibu tena !!"],
            "next_state": "end",
        },
    },
    id=2,
)
```

### Update a bot from file

You can update your bot from a file as follows;

```python
from sarufi import Sarufi

sarufi = Sarufi(api_key='your API KEY')


if __name__ == "__main__":
    response = sarufi.update_from_file(
        id=5,
        intents="data/intents.yaml",
        flow="data/flows.yaml",
        metadata="data/metadata.yaml",
    )
    print(response.data)
```

## Using it in a conversation

Here you have to know the bot ID and also specify your user unique ID;

```python
>>> from sarufi import Sarufi
>>> sarufi = Sarufi(api_key='your API KEY')
2022-08-23 18:30:32,918 - root - INFO - Getting token
>>> bots = sarufi.bots()
2022-08-23 18:30:38,223 - root - INFO - Getting bots
>>> bots
[Bot(id=4, name=iBank), Bot(id=5, name=Maria)]
>>> maria = bots[1]
>>> maria.respond('Hi')
2022-08-23 18:30:52,065 - root - INFO - Sending message to bot and returning response
2022-08-23 18:30:54,126 - root - INFO - Status code: 200
2022-08-23 18:30:54,127 - root - INFO - Message sent successfully
{'message': [['vipi uhali gani?'], ['umeshindaje?'], ['mzima wewe?'], ['Hello! u hali gani ?'], ['Freshi nambie ?'], ['Hi, mzima wewe'], ['salama sijui wewe'], ['za kwako?'], ['Vipi hali yako'], ['Uhali gani?']]}
>>> maria.respond("mi mzima wa afya")
2022-08-23 18:31:02,245 - root - INFO - Sending message to bot and returning response
2022-08-23 18:31:04,237 - root - INFO - Status code: 200
2022-08-23 18:31:04,237 - root - INFO - Message sent successfully
{'message': [['Ninafurahi kujua uko salama'], ['nimefurahi kusikia kutoka kwako'], ['Nipo salama pia, nimefurahi kusikia kutoka kwako'], ['Napenda kukuona ukiwa na furaha'], ['Nimefurahi kusikia hivyo'], ['Salama kabisa'], ['Mzima kabisa']]}
```

### Get a bot

Query a bot by ID

```python
>>> from sarufi import Sarufi
>>> sarufi = Sarufi(api_key='your API KEY')
>>> maria= sarufi.get_bot(5)
2022-08-23 18:44:05,473 - root - INFO - Getting token
>>> maria
Bot(id=5, name=Maria)
```

## Deleting a bot

Delete a bot by ID

```python
>>> from sarufi import Sarufi
>>> sarufi = Sarufi(api_key='your API KEY')
>>> sarufi.delete_bot(5)
```

### Issues ?

Are you facing any issue with the usage of the package, please raise one

## Contributors

1. [kalebu](https://github.com/kalebu/)
2. [Anthony Mipawa](https://github.com/Tonyloyt)
</samp>

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Neurotech-HQ/sarufi-python-sdk",
    "name": "sarufi",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "sarufi, Sarufi Python SDK, Conversation API python, Swahili Conversational API, Conversational platform Python",
    "author": "Jordan Kalebu",
    "author_email": "isaackeinstein@gmail.com",
    "download_url": "https://github.com/Neurotech-HQ/sarufi-python-sdk/archive/refs/tags/v0.0.2.tar.gz",
    "platform": null,
    "description": "<samp>\n\n# sarufi-python-sdk\n\nSarufi Python SDK to help you interact with SARUFI platform\n\n## Installation\n\nMake sure you have [sarufi package](https://github.com/Neurotech-HQ/sarufi-python-sdk) installed on your machine before launching your telegram bot, you can easily install by the following command;\n\n```bash\ngit clone https://github.com/Neurotech-HQ/sarufi-python-sdk\ncd sarufi-python-sdk\nsarufi-python-sdk $ python setup.py install\n```\n\n## Authentication\n\nTo authenticate you're bot, you have to specify your client_id and password for Sarufi Platform just as shown below;\n\n```python\n>>> from sarufi import Sarufi\n>>> sarufi = Sarufi(api_key='your API KEY')\n```\n\n## Creating a Bot\n\nTo create you're bot with sarufi, you have to be aware of two importants idea or concepts which is **intents** and **flow**.\n\nHere an example on how to create your bot;\n\n```python\nsarufi.create_bot(\n    name=\"Athony bot\",\n    description=\"My bot can do a lot\",\n    intents={\n        \"salamu\": [\"Mambo\", \"Hi\", \"Hello\", \"Niaje\"],\n        \"contact\": [\n            \"naomba mawasiliano\",\n            \"naomba number\",\n            \"naomba namba\",\n            \"nipe mawasiliano\",\n            \"nipe contact\",\n        ],\n    },\n    flow={\n        \"salamu\": {\"message\": [\"Hi\", \"Naimani upo salama\"], \"next\": \"end\"},\n        \"contact\": {\n            \"message\": [\"Ungependa kupata namba ya nani ?\"],\n            \"next_state\": \"chukua_namba\",\n        },\n        \"chukua_namba\": {\n            \"message\": [\"Namba ya huyo mtu ni 07374734737\", \"Karibu tena !!\"],\n            \"next_state\": \"end\",\n        },\n    },\n)\n```\n\n### Creating a Bot from file\n\nYou can create your bot from a file, Here is an example on how to create your bot from a file;\n\n```python\nfrom sarufi import Sarufi\n\nsarufi = Sarufi(api_key='your API KEY')\n\n\nif __name__ == \"__main__\":\n    response = sarufi.create_from_file(\n        intents=\"data/intents.yaml\",\n        flow=\"data/flows.yaml\",\n        metadata=\"data/metadata.yaml\",\n    )\n    print(response.data)\n```\n\n## Updating bot\n\nUpdating the bot is comparatively similar to creating a bot but this time you have to explicity specify the **project ID** of your bot.\n\n```python\nsarufi.update_bot(\n    name=\"Athony bot\",\n    description=\"My bot can do a lot\",\n    intents={\n        \"salamu\": [\"Mambo\", \"Hi\", \"Hello\", \"Niaje\"],\n        \"contact\": [\n            \"naomba mawasiliano\",\n            \"naomba number\",\n            \"naomba namba\",\n            \"nipe mawasiliano\",\n            \"nipe contact\",\n        ],\n    },\n    flow={\n        \"salamu\": {\"message\": [\"Hi\", \"Naimani upo salama\"], \"next\": \"end\"},\n        \"contact\": {\n            \"message\": [\"Ungependa kupata namba ya nani ?\"],\n            \"next_state\": \"chukua_namba\",\n        },\n        \"chukua_namba\": {\n            \"message\": [\"Namba ya huyo mtu ni 07374734737\", \"Karibu tena !!\"],\n            \"next_state\": \"end\",\n        },\n    },\n    id=2,\n)\n```\n\n### Update a bot from file\n\nYou can update your bot from a file as follows;\n\n```python\nfrom sarufi import Sarufi\n\nsarufi = Sarufi(api_key='your API KEY')\n\n\nif __name__ == \"__main__\":\n    response = sarufi.update_from_file(\n        id=5,\n        intents=\"data/intents.yaml\",\n        flow=\"data/flows.yaml\",\n        metadata=\"data/metadata.yaml\",\n    )\n    print(response.data)\n```\n\n## Using it in a conversation\n\nHere you have to know the bot ID and also specify your user unique ID;\n\n```python\n>>> from sarufi import Sarufi\n>>> sarufi = Sarufi(api_key='your API KEY')\n2022-08-23 18:30:32,918 - root - INFO - Getting token\n>>> bots = sarufi.bots()\n2022-08-23 18:30:38,223 - root - INFO - Getting bots\n>>> bots\n[Bot(id=4, name=iBank), Bot(id=5, name=Maria)]\n>>> maria = bots[1]\n>>> maria.respond('Hi')\n2022-08-23 18:30:52,065 - root - INFO - Sending message to bot and returning response\n2022-08-23 18:30:54,126 - root - INFO - Status code: 200\n2022-08-23 18:30:54,127 - root - INFO - Message sent successfully\n{'message': [['vipi uhali gani?'], ['umeshindaje?'], ['mzima wewe?'], ['Hello! u hali gani ?'], ['Freshi nambie ?'], ['Hi, mzima wewe'], ['salama sijui wewe'], ['za kwako?'], ['Vipi hali yako'], ['Uhali gani?']]}\n>>> maria.respond(\"mi mzima wa afya\")\n2022-08-23 18:31:02,245 - root - INFO - Sending message to bot and returning response\n2022-08-23 18:31:04,237 - root - INFO - Status code: 200\n2022-08-23 18:31:04,237 - root - INFO - Message sent successfully\n{'message': [['Ninafurahi kujua uko salama'], ['nimefurahi kusikia kutoka kwako'], ['Nipo salama pia, nimefurahi kusikia kutoka kwako'], ['Napenda kukuona ukiwa na furaha'], ['Nimefurahi kusikia hivyo'], ['Salama kabisa'], ['Mzima kabisa']]}\n```\n\n### Get a bot\n\nQuery a bot by ID\n\n```python\n>>> from sarufi import Sarufi\n>>> sarufi = Sarufi(api_key='your API KEY')\n>>> maria= sarufi.get_bot(5)\n2022-08-23 18:44:05,473 - root - INFO - Getting token\n>>> maria\nBot(id=5, name=Maria)\n```\n\n## Deleting a bot\n\nDelete a bot by ID\n\n```python\n>>> from sarufi import Sarufi\n>>> sarufi = Sarufi(api_key='your API KEY')\n>>> sarufi.delete_bot(5)\n```\n\n### Issues ?\n\nAre you facing any issue with the usage of the package, please raise one\n\n## Contributors\n\n1. [kalebu](https://github.com/kalebu/)\n2. [Anthony Mipawa](https://github.com/Tonyloyt)\n</samp>\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Opensource python wrapper to Sarufi Conversation API",
    "version": "0.1.9",
    "project_urls": {
        "Download": "https://github.com/Neurotech-HQ/sarufi-python-sdk/archive/refs/tags/v0.0.2.tar.gz",
        "Homepage": "https://github.com/Neurotech-HQ/sarufi-python-sdk"
    },
    "split_keywords": [
        "sarufi",
        " sarufi python sdk",
        " conversation api python",
        " swahili conversational api",
        " conversational platform python"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f72688a8360e33ad3dd37cad30b0b75d544b39083e715deaf07a7208cf4a5135",
                "md5": "df8f494389554271578671c182b3f94e",
                "sha256": "232dae3c36c9fc123f39356b8f517bdba2c0907c70166d2070ecfd7e266d9af9"
            },
            "downloads": -1,
            "filename": "sarufi-0.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df8f494389554271578671c182b3f94e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 13203,
            "upload_time": "2024-04-05T16:44:53",
            "upload_time_iso_8601": "2024-04-05T16:44:53.909448Z",
            "url": "https://files.pythonhosted.org/packages/f7/26/88a8360e33ad3dd37cad30b0b75d544b39083e715deaf07a7208cf4a5135/sarufi-0.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-05 16:44:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Neurotech-HQ",
    "github_project": "sarufi-python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "sarufi"
}
        
Elapsed time: 0.20982s