自定义操作可以运行我们想要的任何代码,包括 API 调用、数据库查询等。想要在故事中使用的任何自定义操作都需要添加到域文件的 actions
部分。
当对话引擎预测要执行的自定义动作时,它会调用 Action Server,并提供以下信息:
{
"next_action": "string",
"sender_id": "string",
"tracker": {
"conversation_id": "default",
"slots": {},
"latest_message": {},
"latest_event_time": 1537645578.314389,
"followup_action": "string",
"paused": false,
"events": [],
"latest_input_channel": "rest",
"active_loop": {},
"latest_action": {},
},
"domain": {
"config": {},
"session_config": {},
"intents": [],
"entities": [],
"slots": {},
"responses": {},
"actions": [],
"forms": {},
"e2e_actions": []
},
"version": "version"
}
Action Server 应该以事件和响应列表进行响应:
{
"events": [{}],
"responses": [{}]
}