示例#1
0
 public function ask_show($slug)
 {
     $ask = \Ask::where('slug', $slug)->firstOrFail();
     $another_asks = \Ask::orderBy(DB::raw("RAND()"))->take(2)->get();
     return View::make('support/ask_show', compact('ask', 'another_asks'));
 }
示例#2
0
 /**
  * Sends a prompt to the user and optionally waits for a response.
  *
  * The ask method allows for collecting input using either speech 
  * recognition or DTMF (also known as Touch Tone). You can either 
  * pass in a fully-formed Ask object or a string to use as the 
  * prompt and an array of parameters.
  *
  * The available parameters are
  *  - choices: (string) The grammar to use in recognizing and validating input
  *  - as: (string) an SSML type hinting how to say the TTS
  *  - event: (string) only say this on certain events (i.e. no input)
  *  - voice: (string) Override the default TTS voice
  *  - attempts: (int) How many times the caller can attempt input before
  *    an error is thrown
  *  - bargein: (bool) Should the user be allowed to barge in before TTS is complete?
  *  - minConfidence: (int) How confident should Tropo be in a speech reco match?
  *  - name: (string) identifies the return value of an ask, so you know the context for 
  *    the returned information. As an example, if you asked the user for their favorite 
  *    color, the name value would be "color" while the returned value might be "blue".
  *  - required: (bool) Is input required here?
  *  - timeout: (float) How long (in seconds) should Tropo wait for input?
  *  - mode: (string) Only applies to the voice channel and can be either 'speech', 'dtmf', or 'both'.
  *  - terminator: (string) This is the touch-tone key (also known as "DTMF digit") that indicates the end of input. 
  *
  * @param string|Ask $ask
  * @param array $params
  * @see https://www.tropo.com/docs/webapi/ask.htm
  */
 public function ask($ask, array $params = NULL)
 {
     if (!is_object($ask)) {
         $voice = isset($this->_voice) ? $this->_voice : null;
         $p = array('as', 'event', 'voice', 'attempts', 'bargein', 'minConfidence', 'name', 'required', 'timeout');
         foreach ($p as $option) {
             ${$option} = null;
             if (is_array($params) && array_key_exists($option, $params)) {
                 ${$option} = $params[$option];
             }
         }
         $say = new Say($ask, $as, null, $voice);
         $params["mode"] = isset($params["mode"]) ? $params["mode"] : null;
         $params["dtmf"] = isset($params["dtmf"]) ? $params["dtmf"] : null;
         $choices = isset($params["choices"]) ? new Choices($params["choices"], $params["mode"], $params["dtmf"]) : null;
         $ask = new Ask($attempts, $bargein, $choices, $minConfidence, $name, $required, $say, $timeout, $voice);
         if (is_array($event)) {
             // If an event was passed in, add the events to the Ask
             foreach ($event as $e => $val) {
                 $ask->addEvent(new Say($val, $as, $e, $voice));
             }
         }
     }
     $this->ask = sprintf($ask);
 }