# Debug custom actions

**URL:** <https://forum.rasa.com/t/debug-custom-actions/41712>\
**Category:** Rasa Open Source\
**Created:** [March 25, 2021, 2:09pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712 "2021-03-25T14:09:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![laboratory](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@laboratory](https://forum.rasa.com/u/laboratory)\
**Post date:** [March 25, 2021, 2:09pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/1 "2021-03-25T14:09:33Z")

</div>

I am curious to know how to debug custom actions similar to the way I would in normal python development to verify my code before dispatching it.

I have tried adding print statements in my custom actions, but I don’t see them.

Currently, I have an action server that is not dispatching anything and would like to debug that

Thanks in anticipation

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [March 25, 2021, 2:17pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/2 "2021-03-25T14:17:14Z")

</div>

The `print`s in your custom actions should appear in the terminal in which you ran `rasa run actions`.

---

<div class="post-metadata">

**Author:** ![laboratory](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@laboratory](https://forum.rasa.com/u/laboratory)\
**Post date:** [March 25, 2021, 2:23pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/3 "2021-03-25T14:23:29Z")

</div>

Thank you. this works correctly. I am trying to use a template to dispatch message. However, in doing so, no message is being dispatched. But when I pass the result of my custom code directly into the dispatcher (without a template), it works correctly.

What do you think could be the cause here?

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [March 25, 2021, 2:25pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/4 "2021-03-25T14:25:38Z")

</div>

Can you show me your code for that custom action?

---

<div class="post-metadata">

**Author:** ![laboratory](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@laboratory](https://forum.rasa.com/u/laboratory)\
**Post date:** [March 25, 2021, 2:28pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/5 "2021-03-25T14:28:03Z")

</div>

```
class ActionCheckWorldStatistics(Action):
    """Check world covid statistics"""

    def name(self) -> Text:
        return "action_check_world_statistics"

    def run(
        self,
        dispatcher: CollectingDispatcher,
        tracker: Tracker,
        domain: Dict[Text, Any],
    ) -> List[Dict[Text, Any]]:

        # slots = {"number": None, "total": None}

        try:
            url = "https://disease.sh/v3/covid-19/all"
            print("here")
            res = requests.get(url)
            jsonResult = res.json()
            todayCases = str(jsonResult["todayCases"])
            totalCases = str(jsonResult["cases"])
            
            print(totalCases)

            # slot["number"] = todayCases
            # slot["total"] = totalCases

            responseVars = {
                "number": todayCases,
                "location": "the world",
                "total": totalCases,
            }

            # dispatcher.utter_message(totalCases)
           dispatcher.utter_message(template="utter_statistics", **responseVars)

        except HTTPError as httpError:
            dispatcher.utter_message(f"HTTP error occurred: {httpError}")
        except Exception as err:
            dispatcher.utter_message(f"Other error occurred: {err}")

        return []
```

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [March 25, 2021, 2:31pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/6 "2021-03-25T14:31:22Z")

</div>

If you’re using Rasa version 2.4.0, `template` does not work, only `response` instead. Both work in 2.4.1 and 2.4.2 though.

`template` will stop working in Rasa 3.0 anyway, so try using `dispatcher.utter_message(response="utter_statistics", **responseVars)`.

---

<div class="post-metadata">

**Author:** ![laboratory](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@laboratory](https://forum.rasa.com/u/laboratory)\
**Post date:** [March 25, 2021, 2:34pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/7 "2021-03-25T14:34:55Z")

</div>

Thank you. All good now

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [March 25, 2021, 2:35pm UTC](https://forum.rasa.com/t/debug-custom-actions/41712/8 "2021-03-25T14:35:08Z")

</div>

Happy to help 🙂
