Skip to content

Commit 53cf77f

Browse files
committed
feat(actions): add hello world action
1 parent 8040637 commit 53cf77f

File tree

7 files changed

+63
-29
lines changed

7 files changed

+63
-29
lines changed
Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
# This files contains your custom actions which can be used to run
2-
# custom Python code.
3-
#
4-
# See this guide on how to implement these action:
5-
# https://rasa.com/docs/rasa/custom-actions
1+
from typing import Any, Text, Dict, List
2+
from rasa_sdk.types import DomainDict
3+
from rasa_sdk import Action, Tracker
4+
from rasa_sdk.executor import CollectingDispatcher
65

76

8-
# This is a simple example for a custom action which utters "Hello World!"
7+
class ActionHelloWorld(Action):
98

10-
# from typing import Any, Text, Dict, List
11-
#
12-
# from rasa_sdk import Action, Tracker
13-
# from rasa_sdk.executor import CollectingDispatcher
14-
#
15-
#
16-
# class ActionHelloWorld(Action):
17-
#
18-
# def name(self) -> Text:
19-
# return "action_hello_world"
20-
#
21-
# def run(self, dispatcher: CollectingDispatcher,
22-
# tracker: Tracker,
23-
# domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
24-
#
25-
# dispatcher.utter_message(text="Hello World!")
26-
#
27-
# return []
9+
def name(self) -> Text:
10+
return "action_hello_world"
11+
12+
async def run(
13+
self,
14+
dispatcher: CollectingDispatcher,
15+
tracker: Tracker,
16+
domain: DomainDict,
17+
) -> List[Dict[Text, Any]]:
18+
19+
dispatcher.utter_message(text="Hello World!")
20+
21+
return []

src/infrastructure/rasa/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ recipe: default.v1
44

55
# The assistant project unique identifier
66
# This default value must be replaced with a unique assistant name within your deployment
7-
assistant_id: placeholder_default
7+
assistant_id: 20250622-131206-odious-vector
88

99
# Configuration for Rasa NLU.
1010
# https://rasa.com/docs/rasa/nlu/components/
1111
language: en
1212

13-
pipeline:
13+
pipeline: null
1414
# # No configuration for the NLU pipeline was provided. The following default pipeline was used to train your model.
1515
# # If you'd like to customize it, uncomment and adjust the pipeline.
1616
# # See https://rasa.com/docs/rasa/tuning-your-model for more information.
@@ -35,7 +35,7 @@ pipeline:
3535

3636
# Configuration for Rasa Core.
3737
# https://rasa.com/docs/rasa/core/policies/
38-
policies:
38+
policies: null
3939
# # No configuration for policies was provided. The following default policies were used to train your model.
4040
# # If you'd like to customize them, uncomment and adjust the policies.
4141
# # See https://rasa.com/docs/rasa/policies for more information.

src/infrastructure/rasa/data/nlu.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@ nlu:
8989
- are you a human?
9090
- am I talking to a bot?
9191
- am I talking to a human?
92+
93+
- intent: hello_world
94+
examples: |
95+
- please tell me hello world
96+
- hello world
97+
- please please please hello world

src/infrastructure/rasa/data/rules.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,8 @@ rules:
1111
steps:
1212
- intent: bot_challenge
1313
- action: utter_iamabot
14+
15+
- rule: Respond with Hello World every time the user wants intent
16+
steps:
17+
- intent: hello_world
18+
- action: action_hello_world

src/infrastructure/rasa/domain.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ intents:
88
- mood_great
99
- mood_unhappy
1010
- bot_challenge
11+
- hello_world
1112

1213
responses:
1314
utter_greet:
@@ -29,6 +30,9 @@ responses:
2930
utter_iamabot:
3031
- text: "I am a bot, powered by Rasa."
3132

33+
actions:
34+
- action_hello_world
35+
3236
session_config:
3337
session_expiration_time: 60
3438
carry_over_slots_to_new_session: true

src/infrastructure/rasa/endpoints.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
# Server which runs your custom actions.
1111
# https://rasa.com/docs/rasa/custom-actions
1212

13-
#action_endpoint:
14-
# url: "http://localhost:5055/webhook"
13+
action_endpoint:
14+
# actions_module: "actions"
15+
url: "http://localhost:5055/webhook"
1516

1617
# Tracker store which is used to store the conversations.
1718
# By default the conversations are stored in memory.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
digraph {
2+
0 [class="start active", fillcolor=green, fontsize=12, label=START, style=filled];
3+
"-1" [class=end, fillcolor=red, fontsize=12, label=END, style=filled];
4+
1 [class=active, fontsize=12, label=action_session_start];
5+
2 [class=active, fontsize=12, label=action_hello_world];
6+
3 [class=active, fontsize=12, label=utter_happy];
7+
4 [class=active, fontsize=12, label=action_hello_world];
8+
6 [class="intent dashed active", label=" ? ", shape=rect];
9+
7 [class="intent active", fillcolor=lightblue, label="/hello_world", shape=rect, style=filled];
10+
8 [class="intent active", fillcolor=lightblue, label="/nlu_fallback", shape=rect, style=filled];
11+
9 [class="intent active", fillcolor=lightblue, label="/hello_world", shape=rect, style=filled];
12+
10 [class="intent active", fillcolor=lightblue, label="/hello_world", shape=rect, style=filled];
13+
0 -> "-1" [class="", key=NONE, label=""];
14+
0 -> 1 [class=active, key=NONE, label=""];
15+
1 -> 7 [class=active, key=0];
16+
2 -> 8 [class=active, key=0];
17+
3 -> 9 [class=active, key=0];
18+
4 -> 6 [class=active, key=NONE, label=""];
19+
4 -> 10 [class=active, key=0];
20+
7 -> 2 [class=active, key=0];
21+
8 -> 3 [class=active, key=0];
22+
9 -> 4 [class=active, key=0];
23+
10 -> 4 [class=active, key=0];
24+
}

0 commit comments

Comments
 (0)