问题
I'm planning to deploy the bot based on rasa with a monitoring engine. So if something goes wrong, I would like bot to start the conversation with a specific user. Is that possible?
回答1:
An easy way to do so, would be to send a user message from your monitoring system to your input channel. So you basically mimic the user initiating the conversation. Note that I directly specify the intent using the /
as prefix.
Start Rasa Core with the REST api exposed:
python -m rasa_core.run -d models --enable-api
Then you can send messages to it, e.g.:
curl --request POST \
--url http://localhost:5005/webhooks/rest/webhook \
--header 'content-type: application/json' \
--data '{
"sender": "<sender_id_of_your_user>",
"message": "/inform_about_failure"
}'
回答2:
@Tobias's solution is the "old way" still valid to manage external events in a pull-based chatbot engine (not just RASA), when we want to push notifications to sender_id
.
With the current RASA release, to run the RASA Core server the cli command is:
rasa run --debug --enable-api -m models
And the curl
request @Tobias specified is still valid with current RASA version:
curl --request POST \
--url http://localhost:5005/webhooks/rest/webhook \
--header 'content-type: application/json' \
--data '{
"sender": "<sender_id_of_your_user>",
"message": "/inform_about_failure"
}'
On the other hand, the suggested way by RASA now (version 1.9.7), is to use external events management.
That way you can specify also the entities along with the intent to be triggered, as the example shows:
curl \
-H "Content-Type: application/json" \
-X POST \
-d '{"name": "EXTERNAL_dry_plant", "entities": {"plant": "Orchid"}}' \
http://localhost:5005/conversations/<sender_id_of_your_user>/trigger_intent
BTW in RASA, sender_id
and conversation_id
are different names for the same thing.
回答3:
Definitely. But rasa_nlu
got nothing to do with this, you will be sending a push_message
from your backend to the chat client from there rasa_nlu
picks up the conversation.
来源:https://stackoverflow.com/questions/53454544/can-rasa-chatbot-initiate-a-conversation