class DvelpFlow::Channels::Base

Attributes

content[RW]
params[RW]
responder[RW]

Public Class Methods

new(params: {}, responder:) click to toggle source
# File lib/dvelp_flow/channels/base.rb, line 6
def initialize(params: {}, responder:)
  self.content = params[:content]
  self.params = params
  self.responder = responder
end

Public Instance Methods

communicate() click to toggle source
# File lib/dvelp_flow/channels/base.rb, line 12
def communicate
  response.final? ? reply_and_connect : reply_and_gather
end

Private Instance Methods

enqueue_task() click to toggle source
# File lib/dvelp_flow/channels/base.rb, line 26
def enqueue_task
  Twilio::TaskRouter::Task.create(task_attributes)
end
reply_and_connect() click to toggle source
# File lib/dvelp_flow/channels/base.rb, line 20
def reply_and_connect
  voice_response.say(content) if content.present?

  enqueue_task
end
reply_and_gather() click to toggle source
# File lib/dvelp_flow/channels/base.rb, line 34
def reply_and_gather
  content
end
response() click to toggle source
# File lib/dvelp_flow/channels/base.rb, line 38
def response
  responder_params = {
    utterance: content,
    session_uuid: params[:session_uuid]
  }

  responder.new(params: responder_params)
end
task_attributes() click to toggle source
# File lib/dvelp_flow/channels/base.rb, line 30
def task_attributes
  { workflow_sid: workflow_sid }
end