🚀 原文地址:https://rasa.com/docs/rasa/custom-actions

    通过自定义动作,你可以运行任何代码,包括 API 调用、数据库查询等。他们可以开灯、在日历中添加事件、检查用户的银行卡余额,甚至你可以想象的任何事情。

    关于实现自定义动作的细节,请阅读 Rasa SDK 的内容。如果想要在故事中使用自定义动作,那么需要在 domain.yml 文件中 actions 部分进行添加。

    当对话引擎预测执行的是自定义动作时,Rasa 会调用 Action Server,并会将以下信息传递过去:

    1. {
    2. "next_action": "string",
    3. "sender_id": "string",
    4. "tracker": {
    5. "conversation_id": "default",
    6. "slots": {},
    7. "latest_message": {},
    8. "latest_event_time": 1537645578.314389,
    9. "followup_action": "string",
    10. "paused": false,
    11. "events": [],
    12. "latest_input_channel": "rest",
    13. "active_loop": {},
    14. "latest_action": {},
    15. },
    16. "domain": {
    17. "config": {},
    18. "session_config": {},
    19. "intents": [],
    20. "entities": [],
    21. "slots": {},
    22. "responses": {},
    23. "actions": [],
    24. "forms": {},
    25. "e2e_actions": []
    26. },
    27. "version": "version"
    28. }

    Action Server 返回的响应如下:

    1. {
    2. "events": [{}],
    3. "responses": [{}]
    4. }