1.2.6 • Published 7 days ago

custom-chatbot-widget v1.2.6

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
7 days ago

Custom-chatbot-widget

Requirements

  • react :^17.0.2
  • react-dom : ^17.0.2

Installation

npm i rasa-custom-chatbox

Usage

import Widget from 'rasa-custom-chatbox'

<Widget
    initPayload={"/get_started"}
    socketUrl={"RASA ENDPOINT"}
    customData={{"language": "en"}}
    title={"Chatbot"}
    subtitle={"Chatbot"}
    inputTextFieldHint={"Type a message..."}
/>

Custom Action

For userInput parameter in dispatcher.utter_message() function, you can use "hide" to hide the input text field or delete it from the function to show the input text field (default).

  1. Datepicker
    class ActionDatePicker(Action):

        def name(self):
            return 'action_date_picker'

        def run(self, dispatcher, tracker, domain):

            ask_datepicker = {
                "type":"datepicker"
            }

            dispatcher.utter_message(text="Please pick the date", attachment=ask_datepicker, userInput="hide")

            return []
  1. DateTimePicker
    class ActionDateTimePicker(Action):

        def name(self):
            return 'action_date_time_picker'

        def run(self, dispatcher, tracker, domain):

            ask_datetimepicker = {
                "type":"datetimepicker"
            }

            dispatcher.utter_message(text="Please pick the date and time", attachment=ask_datetimepicker, userInput="hide")

            return []
  1. File Downloader

Note: On your my_actions.py file, you need to import json library for json.dumps() function.

class ActionFileDownloader(Action):

    def name(self):
        return 'action_file_downloader'

    def run(self, dispatcher, tracker, domain):

        headersList = {
            // put header here
        }

        bodyContent = json.dumps({
            // put body here
        })

        ask_file_downloader = {
            "type":"filedownloader",
            "endpoint": // url here,
            "body": bodyContent,
            "headers": headersList,
            "filename": // filename here,
        }

        dispatcher.utter_message(attachment=ask_file_downloader, userInput="hide")

        return []
  1. (User) File Upload
    class ActionFileUploader(Action):

        def name(self):
            return 'action_file_uploader'

        def run(self, dispatcher, tracker, domain):

            ask_file_uploader = {
                "type":"fileuploader",
                "uri" : "https://xxxx",
                "uagent" : "user-agent",
                "token" : "JWT",
                "PREFIX" : "module",
                "code": "code module"
            }

            dispatcher.utter_message(text="Upload file below", attachment=ask_file_uploader)

            return []
  1. action human handoff

    Note: This is a custom action to send the socketIO endpoint

class ActionHandOff(Action):
    def name(self):
        return "action_handoff"

    def run(self, dispatcher, tracker, domain):
        server_socketio = "http://localhost:3006"
        dispatcher.utter_message(
            text=server_socketio,
        )
        return []
  1. action Charts
class ActionChart(Action):

    def name(self):
        return 'action_chart'

    def run(self, dispatcher, tracker, domain):

        chart_information = {
            type: "charts",
            chartType: "pie",
            title : "Leave Report",
            data : [300, 50, 100],
            labels : ["Sick Leave", "Unpaid Leave", "Annual Leave"],
            colors : ["#36a2eb", "#ffcd56", "#ff6384"] 
            NOTE: for line chart, use "colors" : "#36a2eb"
        }

        dispatcher.utter_message(attachment=chart_information, userInput="hide")

        return []
  1. action Collapsible
class ActionCollapsible(Action):

    def name(self):
        return 'action_collapsible'

    def run(self, dispatcher, tracker, domain):

        data = {
            type: "collapsible",
            collapsible_payload : [
                {
                    title: "Title 1",
                    content: "<p> Content 1 is <strong>here</strong> </p>"
                },
                {
                    title: "Title 2",
                    content: "<p> Content 2 is <strong>here</strong> </p>"
                }
            ]
        }

        dispatcher.utter_message(attachment=data, userInput="hide")

        return []
  1. action HTML Renderer
class ActionHTMLRenderer(Action):

    def name(self):
        return 'action_html_renderer'

    def run(self, dispatcher, tracker, domain):

        data = {
            type: "htmlrenderer",
            html_payload : "<span>Example for <strong>htmlrenderer</strong> </span>"
        }

        dispatcher.utter_message(attachment=data, userInput="hide")

        return []
  1. action Suggestion
class ActionSuggestion(Action):
    
    def name(self):
        return 'action_sugggestion'

    def run(self, dispatcher, tracker, domain):

        dispatcher.utter_message(
            text="Suggestion for you",
            quick_replies=[
                {
                    "payload":'/payload',
                    "title": "Suggestion 1",
                    "type": "postback",
                },
                {
                    "payload":'/payload',
                    "title": "Suggestion 2",
                    "type": "postback",
                },
                {
                    "payload":'/payload',
                    "title": "Suggestion 3",
                    "type": "postback",
                }
            ]
        )


        return []
1.2.6

7 days ago

1.2.5-5

7 days ago

1.2.5-2

8 days ago

1.2.5-4

8 days ago

1.2.5-3

8 days ago

1.2.5-1

9 days ago

1.2.5

11 days ago

1.2.4-5

11 days ago

1.2.4-4

11 days ago

1.2.4-1

15 days ago

1.2.4

15 days ago

1.2.3

15 days ago

1.2.4-3

15 days ago

1.2.4-2

15 days ago

1.2.2

1 month ago

1.2.0

1 month ago

1.0.3-5.2

1 month ago

1.2.1

1 month ago

1.0.3-6

1 month ago

1.0.3-5.1

1 month ago

1.0.35

2 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.22

7 months ago

1.0.21

7 months ago

1.0.20

8 months ago

1.0.26

6 months ago

1.0.25

6 months ago

1.0.24

6 months ago

1.0.23

6 months ago

1.0.29

6 months ago

1.0.28

6 months ago

1.0.27

6 months ago

1.0.33

6 months ago

1.0.32

6 months ago

1.0.10

9 months ago

1.0.31

6 months ago

1.0.30

6 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.34

6 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago