Skip to main content

Django webhook for ChatBotAI

Project description

A Django wrapper with webhook for ChatbotAI

Example code

Installation

pip install django-chatbot

Usage

For Web Bot

in settings.py add the following:

 INSTALLED_APPS = [
  ...
  'django.chatbot',
  ...
]

CHATBOT_TEMPLATE = <ChatBotAI template file path>
START_MESSAGE = "Welcome to ChatBotAI"

in urls.py add the following:

 from django.chatbot.views import web_hook


 urlpatterns = [
   ...
   path("webhook/", web_hook, name="webhook"),
   ...
]

Web Hook API (should authenticate before API request)

URL: /webhook/
Method: POST
Data: {
        last_message_id: 5,
        message: "what is dosa"
      }
Response: {
      "status": "Success",
      "messages": [
           {
             "id": 6, "text": "what is dosa",
             "created": "2020-03-22 19:42:59",
             "by": "user"
            }, {
              "id": 7,
              "text": "A dosa is a cooked flat thin layered rice batter, originating from South India, made from a fermented batter....",
              "created": "2020-03-22 19:42:59",
              "by": "bot"
            }
      ]
}

For Microsoft Bot Framework Webhook

pip install django-background-task

in settings.py add the following:

 INSTALLED_APPS = [
  ...
  'background_task',
  'django.chatbot',
  ...
]

CHATBOT_TEMPLATE = <ChatBotAI template file path>
START_MESSAGE = "Welcome to ChatBotAI"
APP_CLIENT_ID = "<Microsoft App ID>"
APP_CLIENT_SECRET = "<Microsoft App Secret>"

in urls.py add the following:

 from django.chatbot.views import botframework

 urlpatterns = [
   ...
   path("webhook/",
        botframework.web_hook,
        name="botframework-webhook"),
   ...
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-chatbot-0.0.2.3.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

django_chatbot-0.0.2.3-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file django-chatbot-0.0.2.3.tar.gz.

File metadata

  • Download URL: django-chatbot-0.0.2.3.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for django-chatbot-0.0.2.3.tar.gz
Algorithm Hash digest
SHA256 def5cae44bdefac194de7387260f2574321bf7a9daa5c23790b723278c7c8a3d
MD5 af8d1d805c37e54c0003334c7c58df1d
BLAKE2b-256 e87fec5ed6f15b86c95b5d5bf02176db9f57515926bcdc1d5bff648fd3986f9f

See more details on using hashes here.

File details

Details for the file django_chatbot-0.0.2.3-py3-none-any.whl.

File metadata

  • Download URL: django_chatbot-0.0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.5

File hashes

Hashes for django_chatbot-0.0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 91130ad1f084aa5c1176eb37e6328c2f83138adfc75486b25e79e1a62b0b2447
MD5 cb54cf18a2080cb841024e78600f1010
BLAKE2b-256 1ea95ad8284fac5a48b42c0994ea63f3b031ca804bebe312531589d76ecf02a1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page