Custom Actions
自定义行为可以运行您想要的任何代码,包括API调用、数据库查询等。它们可以打开指示灯、将事件添加到日历、检查用户的银行余额,或者您可以想象的任何其他操作。
有关如何实现自定义行为的详细信息,请参阅SDK文档。您想在故事中使用的任何自定义行为都应该添加到domain
的actions
部分。
当对话引擎预测要执行的自定义行为时,它将调用行为服务器,并提供以下信息:
{
"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"
}
行为服务器应使用事件和响应列表进行响应:
{
"events": [{}],
"responses": [{}]
}