【问题标题】:Using RASA to build an email-bot - in general about email-bots dialog management使用 RASA 构建电子邮件机器人 - 一般关于电子邮件机器人对话管理
【发布时间】:2020-05-19 17:17:00
【问题描述】:

我提交了一个关于如何构建通过电子邮件渠道运行的机器人的一般性问题。 具体来说,关于如何使用RASA寻找解决方案。

1.电子邮件网关服务器

发送和接收邮件自动化似乎是一项“不难”的网关任务。需要一个网关服务器,通过 IMAP 接收邮件并调用 RASA REST API,回复 RASA Core 答案,通过 SMTP 向用户发送邮件。

问题 1:

有任何已经完成的电子邮件网关可用作连接器 RASA(或任何其他会话引擎)?


2。电子邮件交换对话管理

电子邮件只是长输入文本的一个例子,包含许多相关的“意图”。这里是具有挑战性的话题。

让我们摆脱通常的聊天范式,机器人和一个人通过几个词/通常只是一个句子,可能在很短的经过时间(秒/分钟)内交换小谈话。在这种情况下,我猜聊天主题在接近回合的聊天序列中非常“上下文化”。聊天可以看作是“同步消息”。

相反,让我们考虑一下仅通过电子邮件交换进行对话的不同场景。

顺便说一句,我的垂直申请涉及一项学术研究 教育领域,关于使用“tutorbot”让学生提问 向导师机器人提出有关课程内容或所有内容的问题 与课程、考试等有关。

在这种情况下,用户作为收件人向机器人发送电子邮件 是一位真正的人类老师(也许学生不知道邮件是否 收件人是真正的人类导师或机器人。待定/部分不相关)。

关键在于,在人与人之间通常的电子邮件通信中,用户在单个文本(信件)中“收集”可能不止一个主题(用我们的话来说是“意图”),它们可能彼此无关(简单),或者它们之间可能存在依赖关系(很难!)。

需要这个“收集”问题/主题是因为电子邮件 是一个异步通信通道,所以人与人之间的电子邮件 交换,在一条消息中收集一堆主题是正常的。 顺便提一句;我将电子邮件称为“异步消息传递”。

问题 2:

如何管理电子邮件交流,来自对话体验 设计,采用 RASA 技术,通常采用基于意图的 对话管理系统?

我的第一个想法是将输入文本标记为多个句子,通过RASA NLU 盲目地处理它们,作为一个意图序列。逐个。 机器人答案将简单地生成 NLG 文本,只是将上述意图的答案连接起来。

用户来信示例:

 Hi Mr. tutor, 

 I'm very interested in topic X mentioned in video Y.
 Can I have more study material? Maybe some papers about it?
 BTW, what's examination next session date? 

 Thanks & regards

 giorgio

导师机器人答案可能是意图答案的串联,答案之间没有任何记忆/关联。这可能适用于简单的情况。看到这个答案:

 Hi Giorgio,

 I'm glad you are interested in topic X. 
 You were right to watch video about Y. 
 That's coherent with your study programme! 
 I also suggest to read these papers: Z, W. 

 The next examination date is to be decided yet. 
 I'll inform you asap via email! 

 Regards

 The teacher

就 RASA 意图而言,输入邮件可能是:

intent greet
intent interest_on
intent interest_more_info
intent next_exam
intent_thanks
intent_signature

就 RASA 的回答而言,输出邮件可能是:

answer_greet
answer_interest_on
answer_interest_more_info
answer_next_exam
answer_signature

到目前为止,这似乎很简单……但是如果输入的句子彼此之间或多或少相关怎么办?

Rasa Core stories,作为对输入邮件的意图序列的预测,理论上似乎是一个成功的解决方案,但我并不完全清楚如何在应用程序代码中实现故事的使用。

您能帮我理解在实践中如何在此电子邮件上下文中使用 RASA 故事吗? 我的意思是:考虑到先前的意图检测,如何使用 RASA 核心来预测下一个意图/答案? 你能给我一个代码示例吗? (我不是 RASA/python 书呆子)

谢谢 乔治

【问题讨论】:

    标签: email chatbot rasa-nlu rasa-core rasa


    【解决方案1】:

    你在 nodejs 中完成的样板实现,只拆分电子邮件文本并将句子发送到 Rasa API Rest。

    对于电子邮件机器人服务,问题在于应定义多意图场景。 Rasa NLU 支持处理多意图场景。

    https://blog.rasa.com/how-to-handle-multiple-intents-per-input-using-rasa-nlu-tensorflow-pipeline/

    【讨论】:

    • Thx Ezio,我的伪代码拆分/序列化和(这可能是棘手的部分)还丢弃了与一系列无趣/不需要的意图(后备/闲聊/感叹/等)相关的响应,以生成一个最终“连贯”的邮件答复。多意图管道需要在 tarining 数据中预见多意图的所有可能组合,这在复杂输入文本的情况下很难。也许多意图是一个加号,以管理少数标准意图组合(肯定+blabla/否定+blabla)......
    • 另一个样板实现是 FormActions。
    【解决方案2】:

    我重新考虑了我的问题,这是我在此处与社区验证的第一个合适的解决方案。因此,我可能只需要“缓冲”传入的邮件句子,将它们拆分并收集/“缓冲”来自机器人的回复,最终作为唯一的电子邮件回复发送。 这里是nodejs的粗略代码:

      const listOfUndesiredIntents = ['chitchat', 'out_of_scope', 'interjection']
    
      /**
       * email reply 
       * @param {String} sender - email address or user id/name
       * @param {String} inputMailText - contains the body text of incoming mail
       * @param {String[]} listOfUndesiredIntents
       * @return {String}
       */
      const emailResponse = (sender, inputMailText, listOfUndesiredIntents) => {
    
        // full text is split into a sequence (array) of sentences.
       const sentences = sentenceTokeniker(inputMailText)
    
        const outputMailText = ''
    
        for (const sentence of sentences) {
          outputMailText += getFiteredRasaCoreResponse(sender, sentence, listOfUndesiredIntents)
    
        return outputMailText
      }
    
    
    const getFiteredRasaCoreResponse = (sender, sentence, listOfUndesiredIntents) => {
    
      const sentenceSeparator = '\n\n'
    
        const reply = await getRASACoreResponse(sender, sentence)
    
        // output mail would contain just "meaningful" contents.
        // it would be better if it doesn't contain answers to some kind of intents, 
        // e.g. answer must removed if related intent is 
        // a fallback, a "not understand", an interjection or (maybe/TBD) any chitchat, etc.
    
        const intent = await getRASALastSelectedIntent(sender)
    
    
        return listOfUndesiredIntents.includes(intent) ? '' : reply + sentenceSeparator 
    
    }
    
    
    const getRasaCoreResponse = (sender, sentence) => {
    
        // submit sentence to RASA engine, calling HTTP POST RASA Core server,
        // to endpoint: http://rasaRunServer:port/webhooks/rest/webhook
    
    }
    
    
    const getRASALastSelectedIntent = (sender) => {
    
        // using RASA API endpoint: conversations/sender/tracker
        // returns intent name corresponding of last message processed
        // for details, see: https://github.com/RasaHQ/rasa/issues/5768#issuecomment-623922786
    
    }
    

    注意:getFiteredRasaCoreResponse() 如果用于修剪“无用”响应 (UtteranceActions)。

    【讨论】:

      猜你喜欢
      • 2010-12-07
      • 1970-01-01
      • 2018-03-03
      • 2017-04-15
      • 1970-01-01
      • 1970-01-01
      • 2017-05-10
      • 2015-01-17
      相关资源
      最近更新 更多