DB Queries not Executing on Slack/AimyBox/WebPage

Hi guys. I have made a bot and have connected it to a mobile application using Aimybox. The stories are being followed and actions are also being triggered that are present in the actions.py file. The only problem is that the sql queries are not being executed. Everything works perfectly fine on Rasa X. The queries too execute perfectly there. I would appreciate it if anyone could help. Thank you!

Here are my files:

endpoints.yml (1.4 KB) stories.md (13.6 KB) nlu.md (9.2 KB) actions.py (15.3 KB) domain.yml (1.8 KB)

Hey @zaidalvi

the sql queries are not being executed

Could you please elaborate on that? I understand that you want the actions.py to run some SQL queries, but what’s the issue you’re facing?

Everything works perfectly fine on Rasa X

Sorry I’m a little confused. If it works, what’s the issue then? :slight_smile:

Hi @degiz . Sorry. What I meant was that when I deploy the bot using Rasa x in terminal it works fine. But when I deploy the bot on a mobile application or a webpage the search query does not execute. It’ll run the action in which the query should be executed but it doesn’t execute the query.

Hey @zaidalvi

Sorry, still not clear.

when I deploy the bot using Rasa x in terminal it works fine

Do you mean that you deploy bot using docker-compose/helm and you can talk to it from Rasa X UI?

it doesn’t execute the query

Probably it makes sense to read the logs from the action server. If you deployed Rasa X with docker-compose, you can get it with:

docker-compose logs app

Hi @degiz I apologize. I’ll explain my entire process. The first thing that I do is run the following command:

rasa run actions

This is the output for that:

Note: I am using JiteshGaikwad’s Rasa_CustoneUI_2.0

The next command that I run is:

rasa run -m models --enable-api --cors “*” --debug

the output for that is:

No error is shown anywhere. However on the index.html this is what I see:

“The Restaurants in Location only:” is a flag in my custom action. So this shows its calling the function but unable to execute the getData() query right after the flag. Its not specific to just this action, any action I run it won’t execute the getData query.

If I run a conversation on Rasa X it runs the query perfectly. I’ll attach my files down below. I’m sorry I was unable to explain it properly before :(. Hopefully this makes my problem clearer. Thank you so much for taking out the time to help me!

domain.yml (1.8 KB) endpoints.yml (1.4 KB) config.yml (622 Bytes) credentials.yml (938 Bytes) actions.py (14.7 KB) index.html (2.0 KB) dbConnect.py (1.3 KB)

@degiz I went in a little deeper. I found that the query is now executing but the results are not displayed.

@degiz From what I have gathered the json_message part is not working.

dispatcher.utter_message(text="Number of Restaurants in Location only: ", json_message = location_count_query_1)

When I use this it starts working. But the problem with this is that the format of the result is all messed up

json_string = json.dumps(location_query_1) dispatcher.utter_message(json_string)

Is there somehow I can show this in a list view?

dispatcher.utter_message(text="Number of Restaurants in Location only: ", json_message = location_count_query_1)

This command used to show data in a proper list view. But since I used json.dumps the format is messed up.

Hey @zaidalvi

Thanks a lot for detailed explanation!

Is there somehow I can show this in a list view?

What about sending response from the utter_message using text parameter? Right now you’re using json_message, and it’s a “free custom text”, that can be interpreted by your UI the way you want it.

I’m not sure which UI you’re using (this chat window), but if you want to continue using json_message, then you have to make sure the UI understands that. If no, I’d stick to text.

Hope that helps!

Hi @degiz. I tried using the following:

dispatcher.utter_message(text=“Restaurants in Location only”) dispatcher.utter_message(text = location_query_1)

It gives me the following error:

AttributeError: ‘list’ object has no attribute ‘strip’

Any ideas as to what can be done to make it work on text?

hey @zaidalvi

it’s a general python string formatting, I’d suggest something like:

dispatcher.utter_message(text=f"Restaurants in Location only: {location_query_1}")
1 Like

You my friend are THE MOST AMAZING PERSON EVER. It finally workeedddd!:grinning:

One last thing if before I get out of your please. :sweat_smile: How can I show it in a list form? Something like:

Restaurant 1

Restaurant 2

Restaurant 3

You are a life savior.