def extract(self, snapshot_id):

        transactions = self.siptransactions.find({"snapshot_id": str(snapshot_id)})

        for transaction in transactions:
            key = transaction['call_id'] + transaction['local_tag'] + transaction['remote_tag']

            if key in self.dialogs.keys():
                # The dialog already exists, just add the message ids
                transaction['_id'] = str(transaction['_id'])
                self.dialogs[key]['transactions'].append(transaction)
            else:

                message = self.networkmessages.find({"_id": ObjectId(transaction['message_ids'][0])})
                sipmessage = SipMessage()
                sipmessage.load(message[0])

                # Parse the sender and receiver
                sender = sipmessage.get_sender()
                receiver = sipmessage.get_receiver()

                transaction['_id'] = str(transaction['_id'])

                # Need to create a new dialog
                self.dialogs[key] = {
                    'snapshot_id': str(snapshot_id),
                    'transactions': [transaction],
                    'sender':      sender,
                    'receiver':    receiver
                }