npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rasa-custom-chatbox

v1.0.4

Published

Custom rasa chat widget

Downloads

2

Readme

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 []