title: Using RASA to build an email-bot - in general about email-bots dialog management
body: <p>I submit a general question about how to build bots running through a email channel.
  Specifically, about how to find solutions using <a href="https://rasa.com/" rel="nofollow noreferrer">RASA</a>.</p>
  
  <p><strong>1. E-MAIL GATEWAY SERVER</strong></p>
  
  <p>Sending and receiving mail automation appears a "not difficult" gateway task. Need a gateway server that receive mails via IMAP and call RASA REST API, answering back RASA Core answers, sending back to user a mail via SMTP.</p>
  
  <p><strong>Question 1:</strong></p>
  
  <blockquote>
    <p>There is any already done email gateway to be used as a connector to
    RASA (or any other conversational engine)?</p>
  </blockquote>
  
  <hr>
  
  <p><strong>2. EMAILS-EXCHANGE DIALOG MANAGEMENT</strong></p>
  
  <p>Emails messages are just an example of long input texts, containing many related "intents". Here the challenging topic. </p>
  
  <p>Let's escape the usual chat paradigm where a bot and a person exchange small talks with a back and forward made by few words / often just a single sentence, possibly in short elapsed time (seconds/minutes). In this scenario I guess the chat topics are pretty "contextualized" in the chat sequences of near turns. Chatting could be see as a "<em>synchronous messaging</em>".</p>
  
  <p>Instead, let's think to a different scenario where conversation happens just via email-exchanges.</p>
  
  <blockquote>
    <p>BTW, My vertical application concerns an academic research in
    educational realms, about using a "tutorbot" to let students to ask
    questions to a tutor bot about contents of a course or everything
    related to the course, examinations, etc.</p>
    
    <p>In this scenario the user send an email to the bot, as the recipient
    were a real human teacher (maybe the student is unaware if the mail
    recipient is a real human tutor or a bot. TBD/partially irrelevant).</p>
  </blockquote>
  
  <p>The point is that within an usual email communication between people, users "collect" in a single text (the letter) maybe more than a single topic (say "intent" in our parlance) that are maybe unrelated each other (simple), or maybe there is a dependence among them (hard!). </p>
  
  <p>The need of this "collection" of questions/topics is because the email
  is an asynchronous communication channel, so between people email
  exchange, is normal to collect in a single message a bunch of topics.
  BTW; I call the email a "<em>asynchronous messaging</em>".</p>
  
  <p><strong>Question 2:</strong></p>
  
  <blockquote>
    <p>How to manage email exchanges, From the conversation experience
    design, with RASA technology, and in general with an intent-based
    dialog management system?</p>
  </blockquote>
  
  <p>My first idea is to tokenize the input text in multiple sentences, blindly processing them though <a href="https://rasa.com/docs/rasa/nlu/about/" rel="nofollow noreferrer">RASA NLU</a>, as a sequence of intents. one by one.
  The bot answer will be trivially produce the NLG text just concatenating answers of above mentioned intents.</p>
  
  <p>Example of user incoming mail:</p>
  
  <pre><code> 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 &amp; regards
  
   giorgio
  </code></pre>
  
  <p>The tutor bot answer could be a concatenation of intents-answers, without any memory/correlation among answers. That's maybe can work for simple cases. See this answer:</p>
  
  <pre><code> 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
  </code></pre>
  
  <p>In terms of RASA intents the input mail could be:</p>
  
  <pre><code>intent greet
  intent interest_on
  intent interest_more_info
  intent next_exam
  intent_thanks
  intent_signature
  </code></pre>
  
  <p>In terms of RASA answers the output mail could be:</p>
  
  <pre><code>answer_greet
  answer_interest_on
  answer_interest_more_info
  answer_next_exam
  answer_signature
  </code></pre>
  
  <p>So far it seems simple... but what if input sentences are much or less related each other?</p>
  
  <p><a href="https://rasa.com/docs/rasa/core/stories/" rel="nofollow noreferrer">Rasa Core stories</a>, as a prediction of sequences of intents, of the input mail, seems in theory a winner solution, but is not fully clear to me how to implement the use of stories in application code.</p>
  
  <p>Can you help me understand in practice how to possibly use RASA stories in this email context?
  I mean: How could use RASA core to predict the next intent/answer, given previous intents detection?
  Can you give me a code example? (I'm not a RASA/python nerd) </p>
  
  <p>Thanks
  giorgio</p>