Beispiel #1
0
def index(request):
    s = Session(request.body)
    t = Tropo()
    t.setVoice('dave')
    # we use what has been set in Tropo object
    t.say(['hello world!'])
    # we use what is set in the method call
    t.say(['hello world!'], voice="allison")

    # we use the voice that has been set in Tropo object
    choices = Choices("[5 digits]").obj
    t.ask(choices,
          say="Please enter your 5 digit zip code.",
          attempts=3,
          bargein=True,
          name="zip",
          timeout=5)

    # we use the voice passed in the method call.
    choices = Choices("[5 digits]").obj
    t.ask(choices,
          say="Please enter your 5 digit zip code.",
          attempts=3,
          bargein=True,
          name="zip",
          timeout=5,
          voice="allison")

    json = t.RenderJson()
    print json
    return json
Beispiel #2
0
def index(request):

	t = Tropo()

        choices = Choices("[4-5 DIGITS]", mode="dtmf", terminator = "#")
	t.ask(choices, timeout=15, name="digit", say = "What's your four or five digit pin? Press pound when finished.", asrLogSecurity="mask", maskTemplate="XDXD-")

	t.on(event = "continue", next ="/continue")

        json = t.RenderJson()

        print json
	return json
Beispiel #3
0
def index(request):
    t = Tropo()
    t.call("sip:[email protected]:5678",
           say="ha ha ha ha ha ah ah ah ah")
    t.say("ah ah ah ah ah uh uh uh uh ha ha ha")
    on1 = On("connect", ask=Ask(Choices("[5 DIGITS]")).json).json
    on2 = On("ring", say="emily2").json
    t.transfer(TO_NUMBER,
               _from=FROM_NUMBER,
               on=[on1, on2],
               choices=TransferOnChoices(terminator='#').json)
    t.say("Hi. I am a robot")
    json = t.RenderJson()
    print json
    return json
Beispiel #4
0
    def test_record(self):
        """
        Test the "record" Tropo class method.
        """

        tropo = Tropo()
        url = "/receive_recording.py"
        choices_obj = Choices("", terminator="#").json
        tropo.record(say="Tell us about yourself", url=url, 
                     choices=choices_obj)
        rendered = tropo.RenderJson()
        pretty_rendered = tropo.RenderJson(pretty=True)
        print "===============test_record================="
        print "render json: %s" % pretty_rendered

        # print "test_record: %s" % tropo.RenderJson()
        rendered_obj = jsonlib.loads(rendered)
        wanted_json = ' {"tropo": [{"record": {"url": "/receive_recording.py", "say": {"value": "Tell us about yourself"}, "choices": {"terminator": "#", "value": ""}}}]}'
        wanted_obj = jsonlib.loads(wanted_json)
        self.assertEqual(rendered_obj, wanted_obj)
Beispiel #5
0
        tropo.ask("[5 digits]",
                  say = Say("Please enter a 5 digit zip code").json)


        tropo.call (TO)
        tropo.conference(ID)
        tropo.hangup()
        tropo.message ("Hello, World", TO)
        tropo.on(event="continue", 
             next="http://example.com/weather.py",
             say="Please hold.")

        tropo.record(say="Please say something for posterity", 
                     url=URL, 
                     choices = Choices("", terminator="#").json)
        tropo.redirect(ID)
        tropo.reject(ID)
        tropo.startRecording(URL)
        tropo.stopRecording()
        tropo.transfer(TO)

        tropo.message("Hello, World",
                      TO, 
                      channel='TEXT', 
                      network='SMS')

    else:
        unittest.main()

Beispiel #6
0
#CPA
mc = MachineDetection(introduction="THis is a CPA test", voice="Victor").json
t.call("+14071234321", machineDetection=mc)

#CPA with Boolean value which will detect CPA with 30 seconds of silence.
t.call("+14071234321", machineDetection=True)

#Conference with join/leave prompts
jp = JoinPrompt(value="Someone just joined the conference",
                voice="Victor").json
lp = LeavePrompt(value="Someone just left the conference", voice="Victor").json
t.conference(id="1234", joinPrompt=jp, leavePrompt=lp)

whisper = {}

c = Choices(value="1", mode="dtmf")
ask = Ask(say="Press 1 to accept this call", choices=c).json
whisper["ask"] = ask

say = Say("You are now being connected to the call").json
whisper["say"] = say

say1 = Say("http://www.phono.com/audio/holdmusic.mp3").json
whisper["ring"] = say1

t.transfer(to="+14071234321", on=whisper)
t.on(event="incomplete", say="You are now being disconnected. Goodbye")

print t.RenderJson()