Method: AdhearsionASR::ControllerMethods#ask
- Defined in:
- lib/adhearsion-asr/controller_methods.rb
#ask(*args) ⇒ Result
Prompts for input, handling playback of prompts, DTMF grammar construction, and execution
The first arguments will be a list of sounds to play, as accepted by #play, including strings for TTS, Date and Time objects, and file paths. :timeout, :terminator and :limit options may be specified to automatically construct a grammar, or grammars may be manually specified.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/adhearsion-asr/controller_methods.rb', line 35 def ask(*args) = args.last.kind_of?(Hash) ? args.pop : {} prompts = args.flatten.compact if block_given? logger.warn "You passed a block to #ask, but this functionality is not available in adhearsion-asr. If you're looking for the block validator functionality, you should avoid using it in favour of grammars, and it is deprecated in Adhearsion Core." end [:grammar] || [:grammar_url] || [:limit] || [:terminator] || raise(ArgumentError, "You must specify at least one of limit, terminator or grammar") grammars = AskGrammarBuilder.new().grammars output_document = prompts.empty? ? nil : output_formatter.ssml_for_collection(prompts) PromptBuilder.new(output_document, grammars, ).execute self end |