Hello everyone, I have not received a response from actions.py
domain.yml file
actions:
- action_activities_offerd #slide products
stories.yml
- story: order shoes
steps:
- intent: order_shoes
- action: utter_brands
- intent: brand_shoes
- action: action_activities_offerd
actions.py
class ActionCarousel(Action):
def name(self) -> Text:
return "action_activities_offerd"
def run(self, dispatcher, tracker: Tracker, domain: "DomainDict") -> List[Dict[Text, Any]]:
message = {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Nike Air Force 1 '07",
"subtitle": "2,649,000đ",
"image_url": "https://static.nike.com/a/images/c_limit,w_592,f_auto/t_product_v1/4f37fca8-6bce-43e7-ad07-f57ae3c13142/air-force-1-07-shoe-WrLlWX.png",
"buttons": [
{
"title": "Giày nam",
"payload": "happy",
"type": "postback"
},
{
"title": "Giày nữ",
"payload": "sad",
"type": "postback"
}
]
},
{
"title": "Carousel 2",
"subtitle": "$12",
"image_url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"buttons": [
{
"title": "Click here",
"url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"type": "web_url"
}
]
}
]
}
}
dispatcher.utter_message(attachment=message)
return []
Hope everybody help please
ChrisRahme
(Chris Rahmé)
October 12, 2021, 5:19am
2
Hello, do you receive a response in rasa shell?
Hi, it still doesn’t work
nik202
(NiK202)
October 12, 2021, 7:45am
4
trinhminhhieu:
@trinhminhhieu Please update the code as shown:
I have add the update the def run please check the updated code.
I have added the / in payload, hope you have mention the intent for the payload?
class ActionCarousel(Action):
def name(self) -> Text:
return "action_activities_offerd"
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]:
message = {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Nike Air Force 1 '07",
"subtitle": "2,649,000đ",
"image_url": "https://static.nike.com/a/images/c_limit,w_592,f_auto/t_product_v1/4f37fca8-6bce-43e7-ad07-f57ae3c13142/air-force-1-07-shoe-WrLlWX.png",
"buttons": [
{
"title": "Giày nam",
"payload": "/happy",
"type": "postback"
},
{
"title": "Giày nữ",
"payload": "/sad",
"type": "postback"
}
]
},
{
"title": "Carousel 2",
"subtitle": "$12",
"image_url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"buttons": [
{
"title": "Click here",
"url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"type": "web_url"
}
]
}
]
}
}
dispatcher.utter_message(attachment=message)
return []
Please delete the older model and re-train it again, and do let us know.
trinhminhhieu:
class ActionCarousel(Action):
def name(self) -> Text:
return "action_activities_offerd"
def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]) -> List[Dict[Text, Any]:
message = {
"type": "template",
"payload": {
"template_type": "generic",
"elements": [
{
"title": "Nike Air Force 1 '07",
"subtitle": "2,649,000đ",
"image_url": "https://static.nike.com/a/images/c_limit,w_592,f_auto/t_product_v1/4f37fca8-6bce-43e7-ad07-f57ae3c13142/air-force-1-07-shoe-WrLlWX.png",
"buttons": [
{
"title": "Giày nam",
"payload": "/happy",
"type": "postback"
},
{
"title": "Giày nữ",
"payload": "/sad",
"type": "postback"
}
]
},
{
"title": "Carousel 2",
"subtitle": "$12",
"image_url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"buttons": [
{
"title": "Click here",
"url": "https://image.freepik.com/free-vector/city-illustration_23-2147514701.jpg",
"type": "web_url"
}
]
}
]
}
}
dispatcher.utter_message(attachment=message)
return []
H
Hi, it still doesn’t work
nik202
(NiK202)
October 12, 2021, 11:44am
6
@trinhminhhieu can you share the error screenshot please?
nik202
(NiK202)
October 12, 2021, 11:52am
9
@trinhminhhieu Right, so you are using scalable mind /chatroom widget. can I request to integrate your chatbot using rasa webchat? If that is not a problem with your use case: Rasa chatbot website integration | Quick tutorial - YouTube OR do you want that code should run on the chatroom ( may be this code is not supportable for the chatroom widget) I am sure, this code will not support the chatroom.
Ref: https://github.com/botfront/rasa-webchat
PS: I would recommend to use rasa-webchat
@nik202
Hi, the following code is not working
script>!(function () {
let e = document.createElement("script"),
t = document.head || document.getElementsByTagName("head")[0];
(e.src =
"https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.js"),
// Replace 1.x.x with the version that you want
(e.async = !0),
(e.onload = () => {
window.WebChat.default(
{
initPayload: '/greet',
customData: { language: "en" },
socketUrl: "http://localhost:5005",
// add other props here
},
null
);
}),
t.insertBefore(e, t.firstChild);
})();
</script>
nik202
(NiK202)
October 12, 2021, 2:45pm
12
@trinhminhhieu hello please update this:
In index.html
<script>!(function () {
let e = document.createElement("script"),
t = document.head || document.getElementsByTagName("head")[0];
(e.src =
"https://cdn.jsdelivr.net/npm/rasa-webchat@1.0.1/lib/index.js"),
// Replace 1.x.x with the version that you want
(e.async = !0),
(e.onload = () => {
window.WebChat.default(
{
initPayload: '/greet',
customData: { language: "en" },
socketUrl: "http://localhost:5005",
// add other props here
},
null
);
}),
t.insertBefore(e, t.firstChild);
})();
</script>
In credentials.yml
socketio:
user_message_evt: user_uttered
bot_message_evt: bot_uttered
session_persistence: true
Note: Please mention the version if you are using rasa version 2.x then 1.0.1 else less then 2.x mention 1.0.0
Please follow the reference video for more clarity!
Good Luck!
nik202:
<script>!(function () {
let e = document.createElement("script"),
t = document.head || document.getElementsByTagName("head")[0];
(e.src =
"https://cdn.jsdelivr.net/npm/rasa-webchat@1.0.1/lib/index.js"),
// Replace 1.x.x with the version that you want
(e.async = !0),
(e.onload = () => {
window.WebChat.default(
{
initPayload: '/greet',
customData: { language: "en" },
socketUrl: "http://localhost:5005",
// add other props here
},
null
);
}),
t.insertBefore(e, t.firstChild);
})();
</script>
Thank you very much! it works!
nik202
(NiK202)
October 12, 2021, 2:56pm
14
@trinhminhhieu No worries! Keep safe!