Beispiel #1
0
 def handleSMS(self, callerID, message, node):
     """ Called when a message is received """
     # See the simpler examples for descriptions of the steps taken in this method
     dialer = IVRDialer(node)
     print 'finding an available outgoing IVR resource'
     dialer.getResource()
     print 'resource found; establishing outgoing call'
     ivr = dialer.dial(callerID)
     ivr.say('You sent the following message')
     ivr.say(message)
     ivr.hangup()
     print 'call completed, application ended'
Beispiel #2
0
 def run(self, node):
     """
        Call-back thread: Run is invoked as soon as the node is started (by mobilIVR.node). In this case it is used to service the call queue by creating outgoing calls to the queued caller-IDs. Queued caller-ids are only 
        serviced if they have been in the queue for a duration longer than C{self.serviceWaitTime}. 
        
        @param node: MobilIVR resource node
        @type node: mobilIVR.node.MobilIVRNode
     """
     while self._serviceQueue:
         
         if (len(self._callerIDQueue) > 0):
             
             # remove duplicate/multiple queued requests from same caller-id
             self._removeDuplicateQueuedCallerIDs()
             
             uniqueIDs = self._callerIDQueue.keys()
             # node._log.info("Queue length " + str(len(uniqueIDs)))
             for uniqueID in uniqueIDs:
                 callerID = str(self._callerIDQueue[uniqueID][0])
                 timeStamp = self._callerIDQueue[uniqueID][1]
                 dialedNumber = str(self._callerIDQueue[uniqueID][2])
                 currentTime = time()
                 
                 if (currentTime - timeStamp > self.serviceWaitTime):
                     node._log.info("Servicing call to " + callerID)
                     try:
                         dialer = IVRDialer(node) # defined in mobilIVR.ivr.__init__
                         node._log.info('finding an available outgoing IVR resource')
                         # find an ivr resource - this is a blocking call handled by the node, returning the address/port of 
                         # an Asterisk Manager API server
                         dialer.getResource()
                         node._log.info('resource found, establishing call with ivr script')
                         # Creates/dials an outbound call, and returns an AGI IVR interface which we can use for interaction 
                         # with the end user
                         ivr = dialer.dial(callerID)
                         ivr.callerID = callerID
                         # set the dialedNumber to the one used to place the missed call
                         ivr.dialedNumber = dialedNumber
                         
                         # create and start the dialog to service the call
                         dialog = self.DialogClass(ivr)
                                                   
                         dialog.run()
                         # ...and hang up the call
                     except Exception, e:
                         node._log.error(e)
                     finally:
                         try:
                             ivr.hangup()
                         except Exception, e:
                             pass
Beispiel #3
0
    def run(self, node):
        """ Called when a message is received """
        try:
		dialer = IVRDialer(node) # defined in mobilIVR.ivr.__init__
		print 'finding an available outgoing IVR resource'
		# find an ivr resource - this is a blocking call handled by the node, returning the address/port of an Asterisk Manager API server
		dialer.getResource()
		print 'resource found, establishing call with ivr script'
		# Creates/dials an outbound call, and returns an AGI IVR interface which we can use for interaction with the end user
		ivr = dialer.dial('00726349901')
		# Greet the user...
		ivr.say('Hello world')
		# ...and hang up the call
	except Exception, e:
		print 'Error: ' + str(e)