示例#1
0
    def post(self):
        t = tropo.Tropo()
        t.say("Welcome to the Tropo web API demo")

        request = "Please press"
        choices_string = ""
        choices_counter = 1
        for key in sorted(DEMOS.iterkeys()):
            if (len(choices_string) > 0):
                choices_string = "%s,%s" % (choices_string, choices_counter)
            else:
                choices_string = "%s" % (choices_counter)
            demo_name = DEMOS[key][0]
            demo = DEMOS[key][1]
            request = "%s %s for %s," % (request, key, demo_name)
            choices_counter += 1
        choices = tropo.Choices(choices_string)

        t.ask(choices,
              say=request,
              attempts=3,
              bargein=True,
              name="zip",
              timeout=5,
              voice="dave")

        t.on(event="continue", next="/demo_continue.py", say="Please hold.")

        t.on(event="error", next="/demo_continue.py", say="An error occurred.")

        json = t.RenderJson()
        logging.info("Json result: %s " % json)
        self.response.out.write(json)
示例#2
0
def WeatherDemo(handler, tropo):
    """
    """
    choices = tropo.Choices("[5 digits]").obj

    tropo.ask(choices,
              say="Please enter your 5 digit zip code.",
              attempts=3,
              bargein=True,
              name="zip",
              timeout=5,
              voice="dave")

    tropo.on(
        event="continue",
        #             next="%s/weather.py?uri=end" % THIS_URL,
        next="/weather.py?uri=end",
        say="Please hold.")

    tropo.on(
        event="error",
        #             next="%s/weather.py?uri=error" % THIS_URL,
        next="/weather.py?uri=error",
        say="Ann error occurred.")

    json = tropo.RenderJson()
    logging.info("Json result: %s " % json)
    pretty = tropo.PrettyJson()
    logging.info("WeatherDemo json: %s" % pretty)

    handler.response.out.write(pretty)
示例#3
0
def RecordDemo(handler, t):

    url = "%s/receive_recording.py" % THIS_URL
    choices_obj = tropo.Choices("", terminator="#").json
    t.record(say="Tell us about yourself", url=url, choices=choices_obj)
    json = t.RenderJson()
    logging.info("Json result: %s " % json)
    handler.response.out.write(json)
示例#4
0
def WeatherDemo(handler, t):
    """
    """
    choices = tropo.Choices("[5 DIGITS]")

    t.ask(choices,
          say="Please enter your 5 digit zip code.",
          attempts=3,
          bargein=True,
          name="zip",
          timeout=5,
          voice="dave")

    t.on(event="continue", next="/weather.py?uri=end", say="Please hold.")

    t.on(event="error",
         next="/weather.py?uri=error",
         say="Ann error occurred.")

    json = t.RenderJson()
    logging.info("Json result: %s " % json)
    logging.info("WeatherDemo json: %s" % json)

    handler.response.out.write(json)