# Custom action doesn't work

**URL:** <https://forum.rasa.com/t/custom-action-doesnt-work/21253>\
**Category:** Rasa Open Source\
**Created:** [November 14, 2019, 1:22pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253 "2019-11-14T13:22:54Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![vivitare](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vivitare](https://forum.rasa.com/u/vivitare)\
**Post date:** [November 14, 2019, 1:22pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/1 "2019-11-14T13:22:54Z")

</div>

I’m trying a simple hello-world in custom action but the bot don’t reply.

this is my action.py file :

```python
from rasa_sdk.events import SlotSet
from rasa_sdk import Action

class ActionHelloWorld(Action):
    def name(self):
        return "action_hello_world"

    def run(self, dispatcher, tracker, domain):
        dispatcher.utter_message("Hello world !") # send the message back to the user
        return []

```

domain.yml :

```auto
actions:
- utter_greet
- utter_goodbye
- utter_searching
- action_hello_world

```

and stories.md :

```nohighlight
## greet + ask_qst
* greet
  - action_hello_world

```

and this is the debugging during shell command :

```nohighlight
Your input -> hey
2019-11-14 13:03:40 DEBUG rasa.core.tracker_store - Creating a new tracker for id 'default'.
2019-11-14 13:03:40 DEBUG rasa.core.processor - Received user message 'hey' with intent '{'name': 'greet', 'confidence': 0.817916027907992}' and entities '[]'
2019-11-14 13:03:40 DEBUG rasa.core.processor - Logged UserUtterance - tracker now has 2 events
2019-11-14 13:03:40 DEBUG rasa.core.policies.memoization - Current tracker state [None, None, None, {}, {'prev_action_listen': 1.0, 'intent_greet': 1.0}]
2019-11-14 13:03:40 DEBUG rasa.core.policies.memoization - There is a memorised next action '8'
2019-11-14 13:03:40 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_0_MemoizationPolicy
2019-11-14 13:03:40 DEBUG rasa.core.processor - Predicted next action 'action_hello_world' with confidence 1.00.
2019-11-14 13:03:40 DEBUG rasa.core.actions.action - Calling action endpoint to run action 'action_hello_world'.
2019-11-14 13:03:40 DEBUG rasa.core.processor - Action 'action_hello_world' ended with events '[]'
2019-11-14 13:03:40 DEBUG rasa.core.policies.memoization - Current tracker state [None, None, {}, {'prev_action_listen': 1.0, 'intent_greet': 1.0}, {'prev_action_hello_world': 1.0, 'intent_greet': 1.0}]
2019-11-14 13:03:40 DEBUG rasa.core.policies.memoization - There is a memorised next action '0'
2019-11-14 13:03:40 DEBUG rasa.core.policies.mapping_policy - There is no mapped action for the predicted intent, 'greet'.
2019-11-14 13:03:40 DEBUG rasa.core.policies.ensemble - Predicted next action using policy_0_MemoizationPolicy
2019-11-14 13:03:40 DEBUG rasa.core.processor - Predicted next action 'action_listen' with confidence 1.00.
2019-11-14 13:03:40 DEBUG rasa.core.processor - Action 'action_listen' ended with events '[]'
2019-11-14 13:03:40 DEBUG rasa.core.lock_store - Deleted lock for conversation 'default'.
Your input ->

```

Why the bot don’t show the dispatcher.utter\_message(“Hello world !”) message defined in the action.py ?

I’m running action server with Docker from rasa/rasa-sdk:latest. rasa version : Rasa 1.5.0a1

---

<div class="post-metadata">

**Author:** ![btotharye](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/btotharye/32/5321_2.png) [@btotharye](https://forum.rasa.com/u/btotharye)\
**Post date:** [November 14, 2019, 2:56pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/2 "2019-11-14T14:56:42Z")

</div>

Just to verify @vivitare you did also start up the action server as well with `rasa run actions`? If not the bot won’t respond

---

<div class="post-metadata">

**Author:** ![vivitare](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vivitare](https://forum.rasa.com/u/vivitare)\
**Post date:** [November 14, 2019, 3:17pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/3 "2019-11-14T15:17:38Z")

</div>

Nope, i’m using docker-compose wich is advisable in the docs : [Running Rasa with Docker](https://rasa.com/docs/rasa/user-guide/running-rasa-with-docker/#adding-the-action-server)

this is my docker-compose.yml file :

```auto
version: '3.0'
services:
  action_server:
    image: rasa/rasa-sdk:latest
    ports:
      - 5005:5005
    volumes:
      - ./actions:/app/actions

```

It is not spécified to run “rasa run actions” with docker-compose but just “docker-compose up”.

---

<div class="post-metadata">

**Author:** ![pkchoudhary1211](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pkchoudhary1211/32/5790_2.png) [@pkchoudhary1211](https://forum.rasa.com/u/pkchoudhary1211)\
**Post date:** [November 15, 2019, 5:41am UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/4 "2019-11-15T05:41:47Z")

</div>

see My Code Which is Working Perfectly it may help You…

```
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
class ActionHelloWorld(Action):
    def name(self):
        return "action_hello_world"
    def run(self, dispatcher, tracker, domain):
        print("Hello Your Name",(tracker.latest_message)['text'])
        print("Here oim ")
        # buttons = []
        print("this is tracker",tracker)
        # buttons.append({"title": "username ","payload": "pok"})
        # buttons.append({"title": "username1 ","payload": "ok"})
        # dispatcher.utter_button_message(buttons)
        dispatcher.utter_message("Hello World!")
        return []

```

and need to run this `python -m rasa_sdk --actions actions`

for run custom action server

now open another cmd window in your rasa project and check `rasa shell`

---

<div class="post-metadata">

**Author:** ![vivitare](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vivitare](https://forum.rasa.com/u/vivitare)\
**Post date:** [November 15, 2019, 8:26am UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/5 "2019-11-15T08:26:15Z")

</div>

I can’t run `python -m rasa_sdk --actions actions` in Docker container. The port 5055 is already in use…

The custom action server is already running. I can show you the log with `docker logs -f [custom action container id] ` :

```auto
[root@wqya1726 chatbot_rasa]# docker logs -f 91e81f9ffcc
2019-11-14 15:50:29 INFO rasa_sdk.endpoint - Starting action endpoint server...
2019-11-14 15:50:29 INFO rasa_sdk.executor - Registered function for 'action_hello_world'.
2019-11-14 15:50:29 INFO rasa_sdk.endpoint - Action endpoint is up and running on http ('0.0.0.0', 5055)

```

And after i run `docker run -it --network="chatbot_rasa_default" -v $(pwd):/app rasa/fr:latest shell -vv `

But no response is returned by the bot and there is nothing in custom action server logs.

---

<div class="post-metadata">

**Author:** ![vivitare](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vivitare](https://forum.rasa.com/u/vivitare)\
**Post date:** [November 15, 2019, 9:26am UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/6 "2019-11-15T09:26:04Z")

</div>

Oh, i tried your code and look at this the action server respond :

```auto
2019-11-15 09:08:28 INFO rasa_sdk.endpoint - Starting action endpoint server...
2019-11-15 09:08:28 INFO rasa_sdk.executor - Registered function for 'action_hello_world'.
2019-11-15 09:08:28 INFO rasa_sdk.endpoint - Action endpoint is up and running on http ('0.0.0.0', 5055)
2019-11-15 09:15:20 WARNING rasa_sdk.endpoint - Your versions of rasa and rasa_sdk might not be compatible. You are currently running rasa version 1.4.5 and rasa_sdk version 1.5.0a1.
To ensure compatibility use the same version for both, modulo the last number, i.e. using version A.B.x the numbers A and B should be identical for both rasa and rasa_sdk.
Hello Your Name yo
Here oim
this is tracker <rasa_sdk.interfaces.Tracker object at 0x7fa2496eaf98>
172.20.0.2 - - [2019-11-15 09:15:20] "POST /webhook HTTP/1.1" 200 283 0.001558

```

i executed `rasa interactive` and always no response :

```auto
? Your input -> yo
? Your NLU model classified 'yo' with intent 'greet' and there are no entities, is this correct? Yes
------
Chat History

 # Bot You
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
 1 action_listen
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
 2 yo
                         intent: greet 0.74
------
? The bot wants to run 'action_hello_world', correct? Yes
------
Chat History

 # Bot You
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
 1 action_listen
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
 2 yo
                                   intent: greet 0.74
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq
 3 action_hello_world 1.00
------
? The bot wants to run 'action_listen', correct? (Y/n)

```

---

<div class="post-metadata">

**Author:** ![pkchoudhary1211](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pkchoudhary1211/32/5790_2.png) [@pkchoudhary1211](https://forum.rasa.com/u/pkchoudhary1211)\
**Post date:** [November 15, 2019, 10:36am UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/7 "2019-11-15T10:36:20Z")

</div>

It’s Working correctly

---

<div class="post-metadata">

**Author:** ![vivitare](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vivitare](https://forum.rasa.com/u/vivitare)\
**Post date:** [November 15, 2019, 10:37am UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/8 "2019-11-15T10:37:46Z")

</div>

Why the bot don’t respond “Hello wolrd !” ?

---

<div class="post-metadata">

**Author:** ![vivitare](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vivitare](https://forum.rasa.com/u/vivitare)\
**Post date:** [November 15, 2019, 10:38am UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/9 "2019-11-15T10:38:09Z")

</div>

Why the bot don’t respond “Hello wolrd !” ?

---

<div class="post-metadata">

**Author:** ![pkchoudhary1211](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/pkchoudhary1211/32/5790_2.png) [@pkchoudhary1211](https://forum.rasa.com/u/pkchoudhary1211)\
**Post date:** [November 15, 2019, 10:40am UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/10 "2019-11-15T10:40:24Z")

</div>

Use Interactive Learning and set by using `rasa interactive` cmd and set your intent to your custom action

---

<div class="post-metadata">

**Author:** ![chriswangweb](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chriswangweb/32/11865_2.png) [@chriswangweb](https://forum.rasa.com/u/chriswangweb)\
**Post date:** [November 18, 2019, 12:34pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/11 "2019-11-18T12:34:09Z")

</div>

rasa interactive is the right way

---

<div class="post-metadata">

**Author:** ![vivitare](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@vivitare](https://forum.rasa.com/u/vivitare)\
**Post date:** [November 18, 2019, 12:36pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/12 "2019-11-18T12:36:43Z")

</div>

It doesn’t working… I opened new topic that resume this topic better :

> [@Can't run custom action with Docker](http://forum.rasa.com/t/cant-run-custom-action-with-docker/21293):
>
> Hey i’m trying to create a chatbot with RASA in Docker but i can’t use custom action, the bot don’t respond. I’m running the action server in a Docker container with docker-compose. This is the docker-compose.yml file : version: '3.0' services: action\_server: image: rasa/rasa-sdk:latest volumes: - ./actions:/app/actions And this is my endpoints.yml file : action\_endpoint: url: "http://action\_server:5055/webhook" To interact with the chatbot, i execute rasa/rasa:latest imag…

---

<div class="post-metadata">

**Author:** ![krkc](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@krkc](https://forum.rasa.com/u/krkc)\
**Post date:** [July 7, 2021, 2:39pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/13 "2021-07-07T14:39:26Z")

</div>

This is because, you have missed the import → from rasa\_sdk.executor import CollectingDispatcher.

---

<div class="post-metadata">

**Author:** ![krkc](https://avatars.discourse-cdn.com/v4/letter/k/90ced4/32.png) [@krkc](https://forum.rasa.com/u/krkc)\
**Post date:** [July 7, 2021, 2:58pm UTC](https://forum.rasa.com/t/custom-action-doesnt-work/21253/14 "2021-07-07T14:58:49Z")

</div>

I have tested it and it’s working with no issues.

The problem is that, you have to import the default package/library which is available in actions.py itself. Then only the dispatcher works.
