使用rasa开发多轮对话机器的时候,发现配置很麻烦,且配置很容易出错,配置之间还存在关联关系,即便是使用界面也很繁琐。本文有一个新的思路,即通过一个引导生成对话机器人的机器人来创建对话机器人。这里以工单类客服机器人为例。
一、首先创建一个引导生成对话的机器人。
1.主要是在actions.py中去构建引导创建的流程,由于没有其它的函数判断填槽的状态,只能自己去控制填槽的状态,通过全局变量去记录当前的状态值。
from typing import Dict, Text, Any, List, Union
from rasa_sdk import Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormValidationAction
from pypinyin import pinyin
import re
import os
from os import path
from os import mkdir
#创建配置及actions代码
from create_utils import (
create_config_yml,
create_data_nlu_yml,
create_data_rules_yml,
create_data_stories_yml,
create_domain_yml,
create_actions_py
)
issues=None
sub_issues=None
collect_fields=None
issue=None
sub_issue=None
collect_field=None
i=0
j=0
k=0
request_other_fields_count = 0
sys_name = None
entities_dict = []
slots_dict = []
nlu_dict = []
utter_ask_dict = []
utter_wrong_dict = []
validate_dict = []
class ValidateCreateForm(FormValidationAction):
"""Example of a form validation action."""
def name(self) -> Text:
return "validate_create_form"
#收集信息生成配置,并自动开始训练
def train(self, sys_name, entities_dict, slots_dict, nlu_dict, utter_ask_dict, validate_dict):
if sys_name:
create_config_yml(sys_name)
create_data_nlu_yml(sys_name, nlu_dict)
create_data_rules_yml(sys_name)
create_data_stories_yml(sys_name)
create_domain_yml(sys_name, entities_dict, slots_dict, utter_ask_dict)
create_actions_py(sys_name, slots_dict, nlu_dict, validate_dict, utter_ask_dict)
if not path.exists(f'{sys_name}/static'):
mkdir(f'{sys_name}/static')
for file_name in ['api.py','html_vue.py','data_utils.py','endpoints.yml','static/bot.jpg','static/dialogue.html','static/user.jpg']:
command = f'cp {file_name} {sys_name}/{file_name}'
output = os.system(command)
print(f"cp {file_name} result:", output)
command = f"cd {sys_name} && rasa train & cd .."
output = os.system(command)
print("rasa train result:", output)
return
#验证系统名称
def validate_sys_name(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
print('sys_name:', value)
#收集系统名称
global sys_name
sys_name = value
return {"sys_name": value}
else:
dispatcher.utter_message(text="请输入系统名称,如:汽车客服工单系统")
return {"sys_name": None}
#验证主要问题分类
def validate_issues(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
value = re.split(',|、',value)
global issues
issues = value
global issue
issue = value[i]
print('issues:',value,'issue:',issue,'i:',i)
#收集实体及槽位
global entities_dict
entities_dict.append(issue +'.issue')
global slots_dict
slots_dict.append(issue + '.issue')
return {"issues": value, "issue": issue}
else:
dispatcher.utter_message(text=f"收集【{issue}】格式不对,各分类之间用,或、分隔开,请重新输入。")
return {"issues": None}
#验证子问题分类
def validate_sub_issues(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
value = re.split(',|、',value)
global sub_issues
sub_issues = value
global sub_issue
sub_issue = value[j]
print('sub_issues:', value,'sub_issue:', sub_issue,"j:",j)
#收集样本并进行实体标注
global nlu_dict
entity_name = '_'.join([v[0] for v in pinyin(issue)])
nlu_dict.append(f'[{sub_issue}]({entity_name})')
return {"sub_issues": value, "sub_issue": sub_issue}
else:
dispatcher.utter_message(text=f"收集【{sub_issue}】格式不对,各子分类之间用,或、分隔开,请重新输入。")
return {"sub_issues": None}
#验证收集的信息字段
def validate_collect_fields(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
if value.find("、")>0:
value = re.split('、',value)
value = list(filter(None, value))
else:
value = [value]
global collect_fields
collect_fields = value
global collect_field
print('collect_fields->k:', k, 'value:', value)
collect_field = value[k]
print('collect_fields:',value,'collect_field:',collect_field,'k:',k)
return {"collect_fields": value, "collect_field": collect_field}
else:
dispatcher.utter_message(text=f"收集【{collect_field}】格式不对,各信息之间用、分隔开,请重新输入。")
return {"collect_fields": None}
#验证收集信息字段的样本,至少要求2个以上
def validate_nlu_examples(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
if value.find("、")>0:
value = re.split('、',value)
value = list(filter(None, value))
else:
value = [value]
print('nlu_examples:',value)
if len(value)<2:
dispatcher.utter_message(text=f"【{collect_fields[k]}】样本数量不足2个,请重新输入。")
return {"nlu_examples": None}
#收集实体和槽位
global entities_dict, slots_dict
entities_dict.append(collect_field + '.' + sub_issue)
slots_dict.append(collect_field + '.' + sub_issue)
#收集样本,并进行实体标注
global nlu_dict
entity_name = '_'.join([v[0] for v in pinyin(collect_field)])
for v in value:
nlu_dict.append(f'[{v}]({entity_name})')
return {"nlu_examples": value, "collect_questions": None}
else:
dispatcher.utter_message(text=f"【{collect_fields[k]}】样本格式不对,请重新输入。")
return {"nlu_examples": None}
#验证收集信息字段的提问
def validate_collect_questions(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
print("collect_questions:",value)
global utter_ask_dict
utter_ask_dict.append({collect_field:value})
return {"collect_questions": value, "need_validate": None}
else:
dispatcher.utter_message(text=f"收集【{collect_field}】提问格式不对,请重新输入。")
return {"collect_questions": None}
#验证是否需要验证
def validate_need_validate(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
print("need_validate:",value)
global issue
global collect_field
global entities_dict
global slots_dict
validate_dict.append({collect_field + '.need_validate': value})
if value == "是":
return {"need_validate": value, "operate": None, "value": None, "error_tips": None}
else:
global k
if k < len(collect_fields)-1:
k = k + 1
collect_field = collect_fields[k]
print('need_validate->collect_field:', collect_field)
print('need_validate->k:',k)
return {
"collect_field": collect_field,
"nlu_examples": None,
"collect_questions": None,
"need_validate": value,
"operate": '-',
"value": '-',
"error_tips": '-',
"need_other_fields": '-'}
if k == len(collect_fields)-1:
global j
if j < len(sub_issues)-1:
j = j + 1
global sub_issue
sub_issue = sub_issues[j]
print('need_validate->sub_issue:', sub_issue)
print('need_validate->j:',j)
#收集样本并进行实体标注
global nlu_dict
entity_name = '_'.join([v[0] for v in pinyin(issue)])
nlu_dict.append(f'[{sub_issue}]({entity_name})')
k = 0
return {
"sub_issue": sub_issue,
"collect_fields": None,
"nlu_examples": None,
"collect_questions": None,
"need_validate": value,
"operate": '-',
"value": '-',
"error_tips": '-',
"need_other_fields": '-'}
if j == len(sub_issues)-1:
k = 0
global i
#中间激活其它信息收集
need_other_fields = tracker.get_slot('need_other_fields')
print("need_validate->need_other_fields:", need_other_fields)
global request_other_fields_count
request_other_fields_count += 1
print("request_other_fields_count:", request_other_fields_count)
if (need_other_fields == None or need_other_fields == '-') and request_other_fields_count % 2 == 1:
return {
"nlu_examples": '-',
"collect_questions": '-',
"need_validate": value,
"need_other_fields": None,
"operate": '-',
"value": '-',
"error_tips": '-'}
if i < len(issues)-1:
i = i + 1
issue = issues[i]
print("need_validate->issue:",issue)
print('need_validate->i:',i)
j = 0
return {
"issue":issue,
"sub_issues": None,
"collect_fields": None,
"nlu_examples": None,
"collect_questions": None,
"need_validate": value,
"operate": '-',
"value": '-',
"error_tips": '-',
"need_other_fields": None
}
if i == len(issues)-1:
i = 0
print("need_validate->issue:",issue)
print('need_validate->i:',i)
#收集实体和槽位
entities_dict.append(issue + '.issue')
slots_dict.append(issue + '.issue')
print("need_validate->所有信息已收集,自动开始进行训练。i=0")
print("sys_name:", sys_name)
print("entities_dict:", entities_dict)
print("slots_dict:", slots_dict)
print("nlu_dict:", nlu_dict)
print("utter_ask_dict:", utter_ask_dict)
print("validate_dict:", validate_dict)
print("utter_wrong_dict:", utter_wrong_dict)
self.train(sys_name, entities_dict, slots_dict, nlu_dict, utter_ask_dict, validate_dict)
return {"need_validate": value,
"operate": '-',
"value": '-',
"error_tips": '-'}
else:
return {"need_validate": None}
#验证收集信息时,若信息格式不对返回的错误提示
def validate_error_tips(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
print("error_tips:",value)
#收集错误提示
global issue
global collect_field
utter_wrong_dict.append({collect_field:value})
global k
if k < len(collect_fields)-1:
k = k + 1
collect_field = collect_fields[k]
print('error_tips->collect_field:', collect_field)
print('error_tips->k:',k)
return {
"collect_field": collect_field,
"nlu_examples": None,
"collect_questions": None,
"error_tips": value,
"operate": None,
"value": None,
"need_validate": None,
"need_other_fields": None,
"other_fields": '-'}
if k == len(collect_fields)-1:
global j
if j < len(sub_issues)-1:
j = j + 1
global sub_issue
sub_issue = sub_issues[j]
print('error_tips->sub_issue:', sub_issue)
print('error_tips->j:',j)
#收集样本并进行实体标注
global nlu_dict
entity_name = '_'.join([v[0] for v in pinyin(issue)])
nlu_dict.append(f'[{sub_issue}]({entity_name})')
k = 0
return {
"sub_issue": sub_issue,
"collect_fields": None,
"nlu_examples": None,
"collect_questions": None,
"error_tips": value,
"operate": None,
"value": None,
"need_validate": None,
"need_other_fields": None,
"other_fields": None}
if j == len(sub_issues)-1:
k = 0
global i
need_other_fields = tracker.get_slot('need_other_fields')
print("error_tips->need_other_fields:", need_other_fields)
global request_other_fields_count
request_other_fields_count += 1
print("request_other_fields_count:", request_other_fields_count)
if (need_other_fields == None or need_other_fields == '-') and request_other_fields_count % 2 == 1:
return {
"nlu_examples": '-',
"collect_questions": '-',
"error_tips": value}
if i < len(issues)-1:
i = i + 1
issue = issues[i]
print("error_tips->issue:",issue)
print('error_tips->i:',i)
global entities_dict
entities_dict.append(issue + '.issue')
global slots_dict
slots_dict.append(issue + '.issue')
j = 0
return {
"issue":issue,
"sub_issues": None,
"collect_fields": None,
"nlu_examples": None,
"collect_questions": None,
"error_tips": value,
"operate": None,
"value": None,
"need_validate": None,
"need_other_fields": None,
"other_fields": None
}
if i == len(issues)-1:
i = 0
print("error_tips->所有信息已收集,自动开始进行训练。")
print("sys_name:", sys_name)
print("entities_dict:", entities_dict)
print("slots_dict:", slots_dict)
print("nlu_dict:", nlu_dict)
print("utter_ask_dict:", utter_ask_dict)
print("validate_dict:", validate_dict)
print("utter_wrong_dict:", utter_wrong_dict)
self.train(sys_name, entities_dict, slots_dict, nlu_dict, utter_ask_dict, validate_dict)
return {"error_tips": value}
else:
dispatcher.utter_message(text=f"【{collect_field}】错误提示格式不对,请重新输入。")
return {"error_tips": None}
#验证收集信息字段时的逻辑运算符
def validate_operate(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value in ['等于','包含','不包含','匹配','在列表中','范围']:
print('operate:', value)
#收集验证的逻辑运算符
global validate_dict
validate_dict.append({collect_field + '.operate':value})
return {"operate": value}
else:
dispatcher.utter_message(text=f"【{collect_field}】验证逻辑操作格式不对,请求重新输入。如:等于,包含,不包含,匹配,在列表中,范围")
return {"operate": None}
#验证收集信息字段的取值
def validate_value(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
print('value:', value)
global validate_dict
validate_dict.append({collect_field +'.value': value})
return {"value": value}
else:
dispatcher.utter_message(text=f"【{collect_field}】验证取值格式不对,请求重新输入。")
return {"value": None}
#验证是否需要收集其它必填信息字段
def validate_need_other_fields(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
print('need_other_fields:', value)
if value == "是":
return {"need_other_fields": value, "other_fields": None}
else:
if i == len(issues)-1:
#收集实体和槽位
global entities_dict
entities_dict.append(issue + '.issue')
global slots_dict
slots_dict.append(issue + '.issue')
print("validate_need_other_fields:所有信息已收集,自动开始进行训练。")
print("sys_name:", sys_name)
print("entities_dict:", entities_dict)
print("slots_dict:", slots_dict)
print("nlu_dict:", nlu_dict)
print("utter_ask_dict:", utter_ask_dict)
print("validate_dict:", validate_dict)
print("utter_wrong_dict:", utter_wrong_dict)
self.train(sys_name, entities_dict, slots_dict, nlu_dict, utter_ask_dict, validate_dict)
return {"need_other_fields": value, "other_fields": '-'}
else:
return {"need_other_fields": value,
"sub_issues": None,
"collect_fields": None,
"nlu_examples": None,
"collect_questions": None,
"error_tips": None,
"operate": None,
"value": None,
"need_validate": None,
"other_fields": '-'}
else:
dispatcher.utter_message(text=f"是否需要收集其它信息格式不对,请求重新输入。")
return {"need_other_fields": None}
#验证收集的其它必填信息字段
def validate_other_fields(
self,
value: Text,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> Dict[Text, Any]:
if value:
if value.find("、")>0:
value = re.split('、',value)
value = list(filter(None, value))
else:
value = [value]
global collect_fields
collect_fields = value
global collect_field
global k
collect_field = value[k]
print('other_fields:',value, 'collect_fields:',value ,'collect_field:',collect_field,'k:',k)
#收集实体和槽位
global entities_dict, slots_dict
entities_dict.append(collect_field + '.' + issue)
slots_dict.append(collect_field + '.' + issue)
return {"other_fields": value,
"collect_fields": collect_fields,
"collect_field": collect_field,
"nlu_examples": None,
"collect_questions": None,
"need_validate": None,
"operate": None,
"value": None,
"error_tips": None
}
else:
dispatcher.utter_message(text=f"收集【{collect_field}】格式不对,各信息之间用、分隔开,请重新输入。")
return {"other_fields": None}
2. domain.yml
version: '3.1'
session_config:
session_expiration_time: 60
carry_over_slots_to_new_session: true
intents:
- 停止
- 创建请求
- 否定
- 打招呼
- 挑战机器人
- 肯定
- 说再见
- 闲聊
forms:
create_form:
ignored_intents:
- 闲聊
required_slots:
- sys_name
- issues
- sub_issues
- collect_fields
- nlu_examples
- collect_questions
- need_validate
- operate
- value
- error_tips
- need_other_fields
- other_fields
slots:
sys_name:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: sys_name
issues:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: issues
sub_issues:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: sub_issues
collect_fields:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: collect_fields
nlu_examples:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: nlu_examples
collect_questions:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: collect_questions
need_validate:
type: text
influence_conversation: false
mappings:
- type: from_intent
intent: 肯定
value: 是
conditions:
- active_loop: create_form
requested_slot: need_validate
- type: from_intent
intent: 否定
value: 否
conditions:
- active_loop: create_form
requested_slot: need_validate
need_other_fields:
type: text
influence_conversation: false
mappings:
- type: from_intent
intent: 肯定
value: 是
conditions:
- active_loop: create_form
requested_slot: need_other_fields
- type: from_intent
intent: 否定
value: 否
conditions:
- active_loop: create_form
requested_slot: need_other_fields
other_fields:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: other_fields
error_tips:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: error_tips
operate:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: operate
value:
type: text
influence_conversation: false
mappings:
- type: from_text
conditions:
- active_loop: create_form
requested_slot: value
collect_field:
type: text
influence_conversation: false
mappings:
- type: custom
issue:
type: text
influence_conversation: false
mappings:
- type: custom
sub_issue:
type: text
influence_conversation: false
mappings:
- type: custom
responses:
utter_ask_sys_name:
- text: 您希望给对话系统设置的名字是?如:汽车客服工单多轮对话系统
utter_ask_issues:
- text: 【{sys_name}】需要收集的问题类别有哪些?如:产品问题、零部件问题、售后问题、销售问题、咨询建议表扬
utter_ask_sub_issues:
- text: |
【{issue}】包含的子类问题有哪些?以【产品问题】为例,如:启动困难、一键启动系统故障、自动启动系统故障
utter_ask_collect_fields:
- text: |
针对【{sub_issue}】需要收集哪些信息呢?以【启动困难】为例,如:故障现象、环境温度
utter_ask_nlu_examples:
- text: |
针对【{collect_field}】请给出2个以上的训练样本,用中文、分隔开。以【故障现象】为例,如:启动多次才成功、点火时间长才能启动;以【环境温度】为例,如:零下8度、10度
utter_ask_collect_questions:
- text: |
收集【{collect_field}】信息时,你希望表达的问句是?以【启动困难】为例,如:是启动多次才成功还是点火时间长才能启动?
utter_ask_need_validate:
- text: |
收集【{collect_field}】信息时,是否需要对其取值进行验证?
utter_ask_need_other_fields:
- text: |
针对【{issue}】,您是否需要收集其它的信息?
utter_ask_other_fields:
- text: |
针对【{issue}】,您需要收集的信息是?以【产品问题】为例,如:车主全名、手机号、车型、车架号、车牌号、特约店
utter_ask_error_tips:
- text: |
收集【{collect_field}】信息验证失败时,你希望表达的提示是? 如:【{collect_field}】数据格式不对或不存在,请重新输入。
utter_ask_value:
- text: |
验证【{collect_field}】时的取值,字符串(含正则表达式)或列表,单位 如:公里、度、转;故障现象 如:点火时间长才能启动;正则表达式 如:手机号、车架号、车牌号可用正则表达式来验证;车型列表 如:雅阁、飞度、冠道;范围 如:转速 1000-9000
utter_ask_operate:
- text: |
验证【{collect_field}】的逻辑操作符,如:等于、包含、不包含、匹配、在列表中、范围
utter_submit:
- text: 您的信息我已经记录下来,我将自动创建【{sys_name}】并进行训练。
utter_说再见:
- text: 感谢您的来电!
utter_闲聊:
- text: 闲聊
utter_ask_continue:
- text: 您要继续吗?
utter_default:
- text: 对不起,小优还不明白您的意思,请重新描述一下。
utter_打招呼:
- text: 您好,我是一个引导创建服务工单多轮对话系统的机器人小优,有什么需要我帮您的吗?
utter_挑战机器人:
- text: 我是一个引导创建服务工单多轮对话系统的机器人,通过rasa开发构建。
utter_restart:
- text: restarted
actions:
- utter_ask_need_validate
- utter_ask_collect_fields
- utter_ask_collect_questions
- utter_ask_error_tips
- utter_ask_issues
- utter_ask_need_other_fields
- utter_ask_nlu_examples
- utter_ask_other_fields
- utter_ask_sub_issues
- utter_ask_sys_name
- utter_打招呼
- utter_说再见
- utter_闲聊
- validate_create_form
3. data/nlu.yml
version: "3.1"
nlu:
- intent: 打招呼
examples: |
- 嗨
- 嘿
- 嗨机器人
- 嘿机器人
- 哈喽
- 早上好
- 大家好
- 机器人你好
- 嗨朋友
- 你好
- hello
- hi
- hei
- intent: 肯定
examples: |
- 是的
- 对的
- 嗯
- 额,是的
- 我们继续吧
- 是
- 对
- 能
- 可以
- 有
- 需要
- yes
- 哦
- 嗯呢
- intent: 否定
examples: |
- 不
- 不是
- 不对
- 这不适合我
- 不可以
- 不能
- 否
- 不需要
- 没有
- no
- intent: 创建请求
examples: |
- 我想创建一个服务工单系统
- 等于、包含、不包含、匹配、在...中
- 产品问题、销售问题、售后问题、零部件、咨询建议表扬
- 启动困难、一键启动系统故障、字段启停系统故障、怠速不稳定、怠速熄火、怠速异响
- 车主姓名、手机号、车型、车架号、车牌号、特约店、车辆目前公里数、故障发生时间、公里数、路况、车速、转速、故障位置、现象描述、出现次数、第N次、第N次的时间、第N次的公里数、维修方案、故障问题、特约店的诊断结果、特约店的解决方案、客户述求、不满原因
- 车主姓名、手机号、车型、车架号、车牌号、零件名称、零部件号、特约店、精品投诉、特约店的解决方案、客户述求、不满原因
- 车主姓名、手机号、车型、车架号、车牌号、特约店、涉及人员、服务不良描述、送点时间、公里数、特约店的解决方案、客户述求、不满原因
- 车主姓名、手机号、车型、车架号、车牌号、特约店、涉及人员、服务不良描述、特约店的解决方案、客户述求、不满原因
- 客户姓名、手机号、咨询内容
- 故障原因、环境温度
- 故障原因、故障步骤
- 故障原因、转速的变化、车辆是否抖动
- 转速、频率
- 转速、部位
- 是否手动挡、故障挡位、车速、转速
- 是否手动挡、故障挡位、部位、路况、车速、转速
- 机油消耗数值、数值来源、故障现象
- 汽油消耗数值、数值来源、故障现象
- 启动多次、点火时间长、
- 熄火
- 转速是多少?
- 温度是多少?
- 出现几次了?
- 是经常熄火吗?
- 是经常发生吗?
- 发生多少次了?
- 启动不起来了
- 发动不了了
- 态度不好
- 无人接待
- 你到了多长时间无人接待呢?
- 到店时间
- 业务繁忙导致冷淡了客户
- 有没有留意到空闲接待员
- 到店目的
- 是否需要预约安排?
- 是启动多次才成功还是点火时间长才能启动?
- intent: 说再见
examples: |
- 嗯,谢谢你!拜拜!
- 再见!
- 好的,谢谢你!
- 谢谢!
- 谢谢你,再见!
- intent: 闲聊
examples: |
- 你怎么样?
- 今天天气怎么样?
- 下雨了吗?
- 天气热不热?
- 下雪了吗?
- 你是学生吗?
- 你真好看
- 你真漂亮
- 你真了不起
- intent: 停止
examples: |
- 你帮不了我
- 你毫无帮助
- 你能给我想要的吗?
- 结束吧
- 还有其它的吗?
- 停止
- intent: 挑战机器人
examples: |
- 你是机器人吗?
- 你是人类吗?
- 我是在和机器人讲话吗?
- 我是在和人类说话吗?
- lookup: 打招呼
examples: |
- 你好
- 你好啊
- 哈喽
- hi
- hello
- 早上好
- 中午好
- 下午好
4. rules.yml
version: "3.1"
rules:
- rule: 打招呼
steps:
- intent: 打招呼
- action: utter_打招呼
- rule: 说再见
steps:
- intent: 说再见
- action: utter_说再见
- rule: 挑战机器人
steps:
- intent: 挑战机器人
- action: utter_挑战机器人
- rule: 闲聊
steps:
- intent: 闲聊
- action: utter_闲聊
- rule: 通过创建请求激活创建表单
steps:
- intent: 创建请求
- action: create_form
- active_loop: create_form
- rule: 提交创建表单
condition:
- active_loop: create_form
steps:
- action: create_form
- active_loop: null
- action: utter_submit
5.stories.yml
version: "3.1"
stories:
- story: 停止表单+继续
steps:
- intent: 创建请求
- action: create_form
- active_loop: create_form
- intent: 停止
- action: utter_ask_continue
- intent: 肯定
- action: create_form
- active_loop: null
- action: utter_submit
- story: 停止表单+停止
steps:
- intent: 创建请求
- action: create_form
- active_loop: create_form
- intent: 停止
- action: utter_ask_continue
- intent: 否定
- action: action_deactivate_loop
- active_loop: null
二、通过与引导生成对话的机器人进行对话,来生成对话机器人。
三、对话完成后工单系统机器人的效果
四、评价
rasa构建对话系统的好处是可以根据具体需求去构建,填写表单过程中可以增加闲聊,打断当前过程,之后也可以续上,缺点是配置繁琐、不够灵活,对话过程基本上都是预先设定好的,没有chatgpt的理解能力强,但是目前chatgpt还达不到自动与客户进行业务处理类的对话。
更多推荐
rasa开发多轮对话机器人进阶
发布评论