Module: sems
Branch: master
Commit: a2d214df36a46325f38949deab93846d60a4da09
URL: 
https://github.com/sems-server/sems/commit/a2d214df36a46325f38949deab93846d60a4da09

Author: Juha Heinanen <[email protected]>
Committer: Juha Heinanen <[email protected]>
Date: 2015-06-10T11:56:52+03:00

apps/examples/ivr_examples: added skeleton of a call center style application

---

Added: apps/examples/ivr_examples/call_center.py

---

Diff:  
https://github.com/sems-server/sems/commit/a2d214df36a46325f38949deab93846d60a4da09.diff
Patch: 
https://github.com/sems-server/sems/commit/a2d214df36a46325f38949deab93846d60a4da09.patch

---

diff --git a/apps/examples/ivr_examples/call_center.py 
b/apps/examples/ivr_examples/call_center.py
new file mode 100644
index 0000000..e803abe
--- /dev/null
+++ b/apps/examples/ivr_examples/call_center.py
@@ -0,0 +1,71 @@
+# Skeleton of a call center style application that answers, plays beep_file
+# to caller and then tries attendants on callee_list in round robin fashion
+# as long as one of them replies
+
+# Author Juha Heinanen <[email protected]>
+
+import time
+
+from log import *
+from ivr import *
+
+beep_file = "/var/lib/sems/audio/general/beep_snd.wav"
+callee_list = ['sip:[email protected]', 'sip:[email protected]']
+
+beeping                   = 1
+connecting                = 2
+connected                 = 3
+
+class IvrDialog(IvrDialogBase):
+
+    def onSessionStart(self):
+
+        self.callee_list = callee_list
+        self.callee_index = 0
+        self.setNoRelayonly()
+        self.state = beeping
+        self.audio_msg = IvrAudioFile()
+        self.audio_msg.open(beep_file, AUDIO_READ)
+        self.enqueue(self.audio_msg, None)
+
+    def onBye(self):
+
+       self.stopSession()
+
+    def onEmptyQueue(self):
+
+        if self.state == beeping:
+            self.state = connecting
+            self.connectTry()
+            return
+
+        return
+    
+    def onOtherReply(self, code, reason):
+
+        debug('call_center: got reply: ' + str(code) + ' ' + reason)
+
+        if self.state == connecting:
+
+            if code < 200:
+                return
+            if code >= 200 and code < 300:
+                self.flush()
+                self.disconnectMedia()
+                self.setRelayonly()
+                self.state = connected
+                debug('call_center: connected to ' + self.callee_uri)
+                return
+            if code >= 300:
+                time.sleep(3)
+                self.connectTry()
+                return
+        else:
+            return
+
+    def connectTry(self):
+
+            self.callee_uri = self.callee_list[self.callee_index]
+            self.callee_index = (self.callee_index + 1) % 2
+            debug('call_center: trying to connectCallee ' + self.callee_uri)
+            self.connectCallee(self.callee_uri, self.callee_uri)

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to