当前位置:网站首页>Rasa对话机器人之HelpDesk (五)
Rasa对话机器人之HelpDesk (五)
2022-06-29 01:10:00 【m0_49380401】
一、HelpDesk智能对话机器人业务流程中的验证功能解析
在HelpDesk智能对话机器人运行业务流程时,需要对用户输入的信息进行验证,验证通过后才能继续调用后台微服务,如果验证不通过,对话机器人可以继续让用户提供正确的信息,直到所有需要收集的信息都通过验证后才提交form。下面通过Rasa提供的interactive模式演示对话机器人如何验证用户输入信息。当用户查询已经创建的incident的状态时,输入以下信息:

NLU模型正确识别用户意图,继续执行:

继续按照提示运行这个form:

这时对话机器人要求用户提供email信息,输入123:

NLU模型把用户意图识别为out_of_scope,并且提示无法提取email,这里的NLU模型就是指NLU pipeline配置文件中使用的duckling,输入信息123显然不符合email格式,所以duckling无法提取email。
如果输入以下信息,即使不是一个有效的email地址:

这时看起来模型能够提取到这个email信息,继续执行:

Slot “email”已经填充了刚才输入的值,查看action server的输出日志:

可以看到Rasa action server收到了Rasa server发过来的验证请求,然后成功执行了验证微服务validate_incident_status_form,我们在domain中可以看到配置了以下两个验证action:

前面提到了HelpDesk对话机器人的主要业务流程包括根据用户输入创建incident和查询已经创建的incident的状态,在这两个流程中会分别使用open_incident_form和incident_status_form来收集用户信息,所以针对每个form都会定义一个validate action来验证每个form需要收集的信息是否符合要求。
二、HelpDesk对话机器人业务流程验证微服务代码解析
- 创建incident验证微服务
下面是微服务类,继承自Rasa SDK的form验证框架类FormValidationAction

在name方法中需要返回在domain配置中定义的action name:

下面是form的定义:

在验证微服务中可以根据上面定义中需要收集的slots信息提供相应的验证方法,在这里只提供了两个重要的slot信息的验证方法。

这个方法会调用内部方法_validate_email执行具体的验证逻辑:

首先对传入的参数值进行检查:

根据用户提供的email从第三方incident管理系统中获取当前用户的身份id:

-如果caller_id有效则同时返回caller_id和email
-如果不能返回单个的caller_id,则说明email无效,这时需要把slot的值设为None
-如果出现报错信息,也需要把slot的值设为None:

下面的方法验证priority是否有效:

如果priority有效则返回值,否则需要把slot的值设为None,并调用模板方法utter_no_priority输出信息给用户:

2. 查询incident状态验证微服务
下面是微服务类,继承自Rasa SDK的form验证框架类FormValidationAction,按照命名规范,这个微服务类的名称前面应该加上”Validate”:

在name方法中需要返回在domain配置中定义的action name:

下面是form的定义:

这个form只需要收集email信息,所以验证方法也只有一个:

实际上就是调用同一个内部方法_validate_email来实现email的验证逻辑。
边栏推荐
- [SV basics] some usage of queue
- Getting started with SQL
- UVM: message mechanism
- 使用.Net驱动Jetson Nano的OLED显示屏
- Is it safe to open an account on great wisdom
- Redis常用命令手册
- 华泰证券安全吗
- Two ways to set up a single Nacos load balancing ribbon polling policy weight
- Ensemble de données sur les visages masqués et méthode de génération des visages masqués
- Breadth first search to catch cattle
猜你喜欢

免疫组化和免疫组学之间的区别是啥?
[Architect (Part 38)] locally install the latest version of MySQL database developed by the server

IT治理方面的七个错误,以及如何避免

最新Justnews主题源码6.0.1开心版+社交问答插件2.3.1+附教程
![[eight part essay] MySQL](/img/8e/719149fb49f1850baf5bab343955bf.jpg)
[eight part essay] MySQL
![[staff] accent mark, gradually stronger mark and gradually weaker mark](/img/5d/5738bd5503d7ed0621932f901c2e8d.jpg)
[staff] accent mark, gradually stronger mark and gradually weaker mark

【火灾检测】基于matlab GUI森林火灾检测系统(带面板)【含Matlab源码 1921期】
![[RRT 3D path planning] rapid expansion of random tree UAV 3D path planning based on MATLAB [including Matlab source code phase 1914]](/img/85/a2c159e7051cca01fe7ea177a5b1eb.png)
[RRT 3D path planning] rapid expansion of random tree UAV 3D path planning based on MATLAB [including Matlab source code phase 1914]

Reasons for high price of optical fiber slip ring

Day 7 scripts and special effects
随机推荐
华泰证券安全吗
【SV 基础】queue 的一些用法
[Architect (Part 38)] locally install the latest version of MySQL database developed by the server
EasyCVR服务private.pem文件被清空,导致无法正常启动该如何处理?
Roson's QT journey 80 qurl class
Nodejs安装和下载
使用.Net驱动Jetson Nano的OLED显示屏
EasyCVR集群版本替换成老数据库造成的服务崩溃是什么原因?
Getting started with SQL
How to solve the problem of Caton screen when easycvr plays video?
【火灾检测】基于matlab GUI森林火灾检测系统(带面板)【含Matlab源码 1921期】
Precautions for installation and use of rotary joint
UI highly adaptive modification scheme
[MCU club] design of GSM version of range hood based on MCU [simulation design]
Esmm reading notes
Is it safe to open a securities account at qiniu business school in 2022?
接雨水系列问题
[js practice every m days] JS export object analysis based on libcef application (steam)
WPF 实现心电图曲线绘制
分析框架——用户体验度量数据体系搭建