Class: Collavre::Api::V1::Mobile::VoiceCommandsController

Inherits:
BaseController show all
Defined in:
app/controllers/collavre/api/v1/mobile/voice_commands_controller.rb

Overview

A plain mic press (no message selected) routes here: the utterance starts a new piece of work in the user’s Inbox#Main, exactly like typing in the inbox chat — dispatch then matches an agent via routing_expression. Replies to a SPECIFIC message go through agent_events#respond instead (they carry the target event id).

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
# File 'app/controllers/collavre/api/v1/mobile/voice_commands_controller.rb', line 13

def create
  text = params[:text].to_s.strip
  return render_speak(:empty_response, action: { type: "noop" }) if text.blank?

  inbox = Collavre::Creative.inbox_for(current_user)
  comment = inbox.comments.create!(content: text, user: current_user)
  render_speak(:sent, action: { type: "message_sent", comment_id: comment.id })
end