How to make rasa run a custom action in the background

Hello every one!

Actually, I want to make a rasa chatbot that runs a YouTube link (when asked) and at the same time it should continue in chatting with the user. The YouTube code is ready and works properly and I have implemented it as a custom action, but after 10 seconds it closes the YouTube page and then completes chatting with the user.

Is there a way to like run all custom actions as a background run?

by the way I am running the custom actions from another terminal.

Your help is totally appreciated!

Welcome to the forum :slight_smile:

This behavior should be treated by your front-end application, not Rasa.

E.g., you can just send the link to the user and it is it that loads it, not the sever.

1 Like

Thanks for your time!

You are totally right, but the point is that I am trying to make this chatbot as a virtual assistant.

So the user will only inform the chatbot like play me some musics for example.

And the chatbot should turn on the music using an API, and then completes chatting at the same time!

So i should run the custom action as a background run, or i should save the chatbot as a model and then i will be sending get requests to get the output which is not an efficient way (because custom actions will be useless)

If you have other suggestions, i will be more than interested to work on them.

Thanks for you help, Hope that anyone can help!

I strongly suggest again to not handle this with the Rasa server.

But, if you really want to do this, it has become more of a Python question than Rasa anyway. You will need to find a way to detach the process from Python, and maybe save the PID into a slot to come back later in case you want to stop it.

1 Like

Thanks for your help!!

I really appreciate it!

I just have 1 last question, is it feasible to return the entities from rasa chatbot.

So i mean instead of responding back a message, i want to it to be returning the extracted entities from the inputted text.

By this way i will be able to run the class related o YouTube outside the rasa server.

1 Like

Yup! In a custom action, you can use tracket.latest_message['entities']

1 Like

Thanks for your help, I have checked it and it works properly.

1 Like