code: def response_delay_text(records):
      
      interactions = defaultdict(list)
      for r in records:
          interactions[r.correspondent_id].append(r)
  
      def _response_delay(grouped):
          ts = ((b.datetime - a.datetime).total_seconds()
                for conv in _conversations(grouped)
                for a, b in pairwise(conv)
                if b.direction == 'out' and a.direction == 'in')
  
          return ts
  
      delays = [r for i in interactions.values() for r in _response_delay(i)
                if r > 0]
  
      return summary_stats(delays)
docs: The response delay of the user within a conversation (in seconds)
  
      The following sequence of messages defines conversations (``I`` for an
      incoming text, ``O`` for an outgoing text, ``-`` for a one minute
      delay): ::
  
          I-O--I----O, we have a 60 seconds response delay and a 240 seconds response delay
          O--O---I--O, we have a 1200 seconds response delay
          I--II---I-I, we don't have a response delay. The user hasn't answered
  
      For this user, the distribution of response delays will be ``[60, 240, 60]``
  
      Notes
      -----
      See :ref:`Using bandicoot <conversations-label>` for a definition of
      conversations. Conversation are defined to be a series of text messages each
      sent no more than an hour after the previous. The response delay can thus
      not be greater than one hour.