{"id":15697321,"url":"https://github.com/uncle-lv/jrasa","last_synced_at":"2025-05-08T23:48:49.292Z","repository":{"id":174226162,"uuid":"648669831","full_name":"uncle-lv/JRasa","owner":"uncle-lv","description":"A Java SDK for Rasa action server","archived":false,"fork":false,"pushed_at":"2023-06-18T02:11:39.000Z","size":64,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-08T23:48:45.075Z","etag":null,"topics":["chatbot","rasa","rasa-sdk"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uncle-lv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-02T14:09:48.000Z","updated_at":"2025-03-14T08:54:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"c060e1e8-38a3-4042-aca1-75756d2726b3","html_url":"https://github.com/uncle-lv/JRasa","commit_stats":null,"previous_names":["uncle-lv/jrasa"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncle-lv%2FJRasa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncle-lv%2FJRasa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncle-lv%2FJRasa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uncle-lv%2FJRasa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uncle-lv","download_url":"https://codeload.github.com/uncle-lv/JRasa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166479,"owners_count":21864467,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatbot","rasa","rasa-sdk"],"created_at":"2024-10-03T19:16:16.315Z","updated_at":"2025-05-08T23:48:49.274Z","avatar_url":"https://github.com/uncle-lv.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JRasa\n![stars](https://img.shields.io/github/stars/uncle-lv/JRasa?style=plastic)  ![issues](https://img.shields.io/github/issues/uncle-lv/JRasa?style=plastic) ![forks](https://img.shields.io/github/forks/uncle-lv/JRasa?style=plastic) ![license](https://img.shields.io/github/license/uncle-lv/JRasa?style=plastic) ![JDK8](https://img.shields.io/badge/JDK-8-important)  ![Rasa](https://img.shields.io/badge/Rasa-3.x-%235b13ec)\n\n[English](https://github.com/uncle-lv/JRasa/blob/main/README.md) | [中文](https://github.com/uncle-lv/JRasa/blob/main/README_zh.md)\n\nA Java SDK for [Rasa action server](https://rasa.com/docs/rasa/action-server).\n\n\n\n## Maven\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github\u003c/groupId\u003e\n  \u003cartifactId\u003ejrasa\u003c/artifactId\u003e\n  \u003cversion\u003e0.1.0-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n\n\n## Compatibility\n\nRasa: \u003e= 3.x\n\n\n\n## Usage\n\nYou should read [the Rasa SDK documentation](https://rasa.com/docs/rasa/action-server) first to figure out the fundamental concepts.\n\n\n\n### Running a Rasa SDK Action Server\n\nYou can run a Rasa SDK Action Server with the Java web framework you like. There is [a SpringBoot demo](https://github.com/uncle-lv/JRasa/tree/main/src/test/java/examples/springboot) for you.\n\n\n\n### Writing Custom Actions\n\n#### Actions\n\n To define a custom action, create a class which implements the interface [Action](https://github.com/uncle-lv/JRasa/blob/main/src/main/java/io/github/jrasa/Action.java). \n\n```java\nimport io.github.jrasa.Action;\nimport io.github.jrasa.CollectingDispatcher;\nimport io.github.jrasa.domain.Domain;\nimport io.github.jrasa.event.Event;\nimport io.github.jrasa.exception.RejectExecuteException;\nimport io.github.jrasa.tracker.Tracker;\n\nimport java.util.List;\n\npublic class CustomAction implements Action {\n    @Override\n    public String name() {\n        return \"action_name\";\n    }\n\n    @Override\n    public List\u003c? extends Event\u003e run(CollectingDispatcher collectingDispatcher, Tracker tracker, Domain domain) throws RejectExecuteException {\n        return Action.empty();\n    }\n}\n```\n\n💡 If no events need to be returned, you can use `Action.empty()` to return an empty list.\n\n\n\n#### Tracker\n\n##### getSlot\n\nBecause Java is a static programming language, you have to assign the type when you get a slot value.\n\nThere is five methods to get a slot value:\n\n- `Object getSlot(String key)`\n- `\u003cT\u003e T getSlot(String key, Class\u003cT\u003e type)`\n- `String getStringSlot(String key)`\n- `Boolean getBoolSlot(String key)`\n- `Double getDoubleSlot(String key)`\n\n\n\n`Object getSlot(String key)` can get a slot value of any type.\n\nWith `\u003cT\u003e T getSlot(String key, Class\u003cT\u003e type)`, you can assign the type of slot value.\n\n`String getStringSlot(String key)` `Boolean getBoolSlot(String key)` `Double getDoubleSlot(String key)` can get the common type of slot value.\n\n💡 Decimal numbers in JSON are deserialized to double in Java, so double is used instead of float.\n\n\n\n#### Dispatcher\n\nThere is a [Message](https://github.com/uncle-lv/JRasa/blob/main/src/main/java/io/github/jrasa/message/Message.java) class to represent responses, because methods don't support default value parameters in Java.\n\nYou can build a `Message` instance with Builder like this:\n\n```java\nMessage message = Message.builder()\n                .text(\"Hello\")\n                .image(\"https://i.imgur.com/nGF1K8f.jpg\")\n                .response(\"utter_greet\")\n                .attachment(\"\")\n                .kwargs(new HashMap\u003cString, Object\u003e(){{\n                    put(\"name\", \"uncle-lv\");\n                }})\n                .build();\n```\n\nAnd then send it with `utterMessage`:\n\n```java\ndispatcher.utterMessage(message);\n```\n\n\n\n#### Events\n\nAll events are subclasses of abstract class [Event](https://github.com/uncle-lv/JRasa/blob/main/src/main/java/io/github/jrasa/event/Event.java). Their properties are the same as in the documentation. Some of them with many  properties should been build with Builder.\n\n\n\n##### SlotSet\n\n```java\nSlotSet SlotSet = new SlotSet(\"name\", \"Mary\");\n```\n\n\n\n##### AllSlotsReset\n\n```java\nAllSlotsReset allSlotsReset = new AllSlotsReset();\n```\n\n\n\n##### ReminderScheduled\n\n```java\nReminderScheduled reminderScheduled = ReminderScheduled.builder(\"EXTERNAL_dry_plant\")\n        .name(\"remind_water_plants\")\n        .entities(new ArrayList\u003cEntity\u003e(){{\n            add(Entity.builder().entity(\"plant\", \"orchid\").build());\n        }})\n      .triggerDateTime(LocalDateTime.parse(\"2018-09-03T11:41:10.128172\", DateTimeFormatter.ISO_LOCAL_DATE_TIME))\n        .build();\n```\n\n\n\n##### ReminderCancelled\n\n```java\nReminderCancelled reminderCancelled = ReminderCancelled.builder()\n                .name(\"remind_water_plants\")\n                .build();\n```\n\n\n\n##### ConversationPaused\n\n```java\nConversationPaused conversationPaused = new ConversationPaused();\n```\n\n\n\n##### ConversationResumed\n\n```java\nConversationResumed conversationResumed = new ConversationResumed();\n```\n\n\n\n##### FollowupAction\n\n```java\nFollowupAction followupAction = new FollowupAction(\"action_say_goodbye\");\n```\n\n\n\n##### UserUtteranceReverted\n\n```java\nUserUtteranceReverted userUtteranceReverted = new UserUtteranceReverted();\n```\n\n\n\n##### ActionReverted\n\n```java\nActionReverted actionReverted = new ActionReverted();\n```\n\n\n\n##### Restarted\n\n```java\nRestarted restarted = new Restarted();\n```\n\n\n\n##### SessionStarted\n\n```java\nSessionStarted sessionStarted = new SessionStarted();\n```\n\n\n\n##### UserUttered\n\n```java\nUserUttered userUttered = UserUttered.builder()\n                .text(\"Hello bot\")\n                .build();\n```\n\n\n\n##### BotUttered\n\n```java\nBotUttered botUttered = BotUttered.builder()\n                .text(\"Hello user\")\n                .build();\n```\n\n\n\n##### ActionExecuted\n\n```java\nActionExecuted actionExecuted = ActionExecuted.builder(\"action_greet_user\")\n                .build();\n```\n\n\n\n#### Special Action Types\n\n##### Knowledge Base Actions\n\n🛠️ Not implemented yet.\n\n\n\n##### Slot Validation Actions\n\nThere is only one difference from the official SDK.\n\nThe methods/functions are named `validate_\u003cslot_name\u003e`/`extract_\u003cslot name\u003e`(snake case) in the official SDK. In JRasa, they should be named `validate\u003cSlotName\u003e`/`extract\u003cSlotName\u003e`(camel case), as naming convention in Java.\n\n\n\n## Contributions\n\nThank you for any feedback.\n\n\n\n## License\n\n[Apache-2.0](https://github.com/uncle-lv/JRasa/blob/main/LICENSE)\n\n\n\n## Thanks\n\n- [Rasa](https://github.com/RasaHQ/rasa)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funcle-lv%2Fjrasa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funcle-lv%2Fjrasa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funcle-lv%2Fjrasa/lists"}