Hello,
I created a Rasa chatbot using 1.1.3 version. And it is working well in local. I want to deploy it to cloud using docker containers. And this bot having rasa server, rasa action server and mongo db , so I created docker-compose file. without using docker-compose file the bot is working well in local but while using docker-compose file it is showing “AttributeError: ‘list’ object has no attribute ‘to_dict’” in docker-compose logs. I am unable to understand why this error is getting. Can anyone have idea about this??
docker-compose file:
version: '2'
services:
rasa:
image: rasa_databaselast
build:
context: .
volumes:
- ./:/app
ports:
- "5005:5005"
command: python3 -m rasa run --enable-api
action:
image: rasa_databaselast
build:
context: ./actions
volumes:
- ./actions:/app
ports:
- "5055:5055"
command : python3 -m rasa run actions
mongo:
image: mongo
ports:
- "27017:27017"
mongo_seed:
build: ./db
links:
- mongo
environment:
- MONGO_URI=mongodb//mongo:27017/admin
Traceback:
Traceback (most recent call last):
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/facebook.py", line 94, in
_handle_user_message
rasa_1 | await self.on_new_message(user_msg)
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/channel.py", line 75, in
handler
rasa_1 | await app.agent.handle_message(*args, **kwargs)
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/agent.py", line 440, in
handle_message
rasa_1 | return await processor.handle_message(message)
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 84, in
handle_message
rasa_1 | await self._predict_and_execute_next_action(message, tracker)
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 350, in
_predict_and_execute_next_action
rasa_1 | action, tracker, message.output_channel, self.nlg, policy, confidence
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 461, in
_run_action
rasa_1 | await self._send_bot_messages(events, tracker, output_channel)
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/processor.py", line 382, in
_send_bot_messages
rasa_1 | await output_channel.send_response(tracker.sender_id, e.message())
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/channel.py", line 175, in
send_response
rasa_1 | **message
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/facebook.py", line 181,
in
send_quick_replies
rasa_1 | self.send(recipient_id, FBText(text=text, quick_replies=quick_replies))
rasa_1 | File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/facebook.py", line 120,
in send
rasa_1 | self.messenger_client.send(element.to_dict(), recipient_id, "RESPONSE")
rasa_1 | File "/usr/local/lib/python3.6/site-packages/fbmessenger/elements.py", line 27, in
to_dict
rasa_1 | d['quick_replies'] = self.quick_replies.to_dict()
rasa_1 | AttributeError: 'list' object has no attribute 'to_dict'
actions.py:
class ActionLifeDb(Action):
def name(self):
return 'action_Life_db'
def run(self, dispatcher, tracker, domain):
full_name = tracker.get_slot("full_name")
name = full_name.split(" ")
first_name = name[0]
last_name = name[1]
dob = tracker.get_slot("dob")
address = tracker.get_slot("address")
email = tracker.get_slot("email")
phone_number = tracker.get_slot("phone_number")
amount = tracker.get_slot("amount")
type_of_life_insurance = tracker.get_slot("type_of_life_insurance")
existing_medical_condition = tracker.get_slot("existing_medical_condition")
life_insurance_period = tracker.get_slot("life_insurance_period")
quotation_no = "AQ"+ str(randint(100000, 999999))
dispatcher.utter_message("Thank you for all the information, {}.".format(full_name))
myclient = pymongo.MongoClient("mongodb://mongo:27017/")
mydb = myclient["admin"]
mycol = mydb["Insurance"]
x = mycol.find({"Fb Id": GetName.fb_id}, {"Policy No": 1, "Insurance_Type": 1})
resp = "You currently have a "
flag = 0
for i in x:
if i.get("Policy No") != None and i.get("Insurance_Type") != None:
flag = flag + 1
ins = i.get("Insurance_Type")
pol = i.get("Policy No")
resp = resp + "{0} insurance with policy number {1} ,".format(ins, pol)
if flag != 0:
dispatcher.utter_message(resp)
dispatcher.utter_template('utter_download_quotation', tracker)
#getdata = mycol.find({"Fb Id":GetName.fb_id}).count()
#if getdata != 0:
#res = "Thank you for all the information, {}. Seeing that you already have a Life
insurance with us, your life insurance has a 10% discount. You can also download your quote
numbered AQxxxxx by clicking here.".format(full_name)
#dispatcher.utter_message(res)
mydict = {"Full Name": full_name,"First Name": first_name,"Last Name": last_name, "DOB":
dob,"Address": address, "Email": email, "Phone Number": phone_number, "Coverage": amount,
"Type": type_of_life_insurance, "Existing Medical Condition":
existing_medical_condition, "life Insurance Period": life_insurance_period,"Fb
Id":GetName.fb_id,"Insurance_Type":"Life","Quotation Number":quotation_no }
y = mycol.insert_one(mydict)
url = "https://sheetsu.com/apis/v1.0su/3364bfa86fac"
payload = {"Full Name": full_name,"First Name": first_name,"Last Name": last_name,
"DOB": dob,"Address": address, "Email": email, "Phone Number": phone_number, "Coverage":
amount,
"Type": type_of_life_insurance, "Existing Medical Condition":
existing_medical_condition, "life Insurance Period": life_insurance_period,"Fb Id":GetName.fb_id
,"Insurance_Type":"Life","Quotation Number":quotation_no}
headers = {
'Demo': "Demo",
'Authorization': "Basic e3t1c2VybmFtZX19Ont7cGFzc3dvcmR9fQ==",
'cache-control': "no-cache",
'Postman-Token': "de8fda5c-61b7-4f13-922a-5889b9f135c1"
}
#response = requests.request("POST", url, data=payload, headers=headers)
message = {
"text": "Would you like help with anything else?",
"quick_replies": [
{
"content_type": "text",
"title": "Yes",
"payload": "/affirm",
},
{
"content_type": "text",
"title": "No",
"payload": "/deny",
}
]
}
dispatcher.utter_custom_json(message)
#print(response.text)
return []
thanks in advance!