can we set asterisk variable outside of call controller

classic Classic list List threaded Threaded
3 messages Options
dev
Reply | Threaded
Open this post in threaded view
|

can we set asterisk variable outside of call controller

dev
I use following code to originate call and update status of call.

class MakeOutboundCall
  attr_accessor :id, :number
  def initialize(id,number)
   
@id=id
    @number=number
    @call_id='assigned number'
  end

  def call_start!
    call = Adhearsion::OutboundCall.new
    call.execute_controller_or_router_on_answer NoticeBoardCallController, {:id => @id, :initiate_from => 'outbound'}
   
call.on_end do |end_event|
      end
      log_info=NoticeboardLog.find_by(:call_id => call.id)
     
log_info.update(:status=> end_event.reason)
   
end
   
call.dial "SIP/#{@number}", :from => @call_id
    NoticeboardLog.create(:call_id => call.id, :noticeboard_id => @id,:outbound_retried=> 0,:phone_number=> @number, :direction => 'Outboundcall', :time => Time.now.to_i)
 
end
end

but call end reason does not reflect actual call status. for instance, call is answered & hangup - status is hangup and also call ring but no answer - status is same hangup with same end_event plateform_code.  
if we can link call id with CDR  of asterisk by setting asterisk variable. then all problem will be resolved. There is a adhearsion-asterisk gem and it can set_variable from call controller. Is there any way to set variable from outside of call controller? Call controller only execute when call is answered  and we can not link if call is failed.  Something like :

require 'adhearsion-asterisk'
class
MakeOutboundCall
  attr_accessor :id, :number
  def initialize(id,number)
   
@id=id
    @number=number
    @call_id='assigned number'
  end

  def call_start!
    call = Adhearsion::OutboundCall.new
    call.execute_controller_or_router_on_answer NoticeBoardCallController, {:id => @id, :initiate_from => 'outbound'}
   
call.on_end do |end_event|
      end
      status=Cdr.find_by(:userfield => call.id).status
     
log_info=NoticeboardLog.find_by(:call_id => call.id)
      log_info.update(:status=> status)
   end
   
call.dial "SIP/#{@number}", :from => @call_id
    NoticeboardLog.create(:call_id => call.id, :noticeboard_id => @id,:outbound_retried=> 0,:phone_number=> @number, :direction => 'Outboundcall', :time => Time.now.to_i)
   
set_variable('CDR(userfield)',call.id))
 
end
end

but set_variable is controller method so it cause error. Is there any way to link or find right call status for each and individual call for now?

I m thinking to little  customize outboundCall class to achieve call status. 
 

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
lcx
Reply | Threaded
Open this post in threaded view
|

Re: can we set asterisk variable outside of call controller

lcx


On 5 Aug 2015, at 7:45, dev wrote:

> I use following code to originate call and update status of call.
>
> class MakeOutboundCall
> attr_accessor :id, :number
> def initialize(id,number)
>  @id=id
>  @number=number
>  @call_id='assigned number'
>
> end
>
> def call_start!
>  call = Adhearsion::OutboundCall.new
>  call.execute_controller_or_router_on_answer
> NoticeBoardCallController, {:id => @id, :initiate_from => 'outbound'}
>  call.on_end do |end_event|
>    end
>    log_info=NoticeboardLog.find_by(:call_id => call.id)
>    log_info.update(:status=> end_event.reason)
>  end
>  call.dial "SIP/#{@number}", :from => @call_id
>  NoticeboardLog.create(:call_id => call.id, :noticeboard_id =>
> @id,:outbound_retried=> 0,:phone_number=> @number, :direction =>
> 'Outboundcall', :time => Time.now.to_i)
> end
> end
>
>
> but call end reason does not reflect actual call status. for instance,
> call
> is answered & hangup - status is hangup and also call ring but no
> answer -
> status is same hangup with same end_event plateform_code.
> if we can link call id with CDR  of asterisk by setting asterisk
> variable.

you can use the uniqueid to find the call in the asterisk CDR. The
UniqueID can be accessed with adhearsion in  variables[:x_agi_uniqueid]
this is the uniqueid that was set in asterisk.

Cris

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: can we set asterisk variable outside of call controller

Ben Langfeld-2
In reply to this post by dev


On 5 August 2015 at 02:45, dev <[hidden email]> wrote:
I use following code to originate call and update status of call.

class MakeOutboundCall
  attr_accessor :id, :number
  def initialize(id,number)
   
@id=id
    @number=number
    @call_id='assigned number'
  end

  def call_start!
    call = Adhearsion::OutboundCall.new
    call.execute_controller_or_router_on_answer NoticeBoardCallController, {:id => @id, :initiate_from => 'outbound'}
   
call.on_end do |end_event|
      end
      log_info=NoticeboardLog.find_by(:call_id => call.id)
     
log_info.update(:status=> end_event.reason)
   
end
   
call.dial "SIP/#{@number}", :from => @call_id
    NoticeboardLog.create(:call_id => call.id, :noticeboard_id => @id,:outbound_retried=> 0,:phone_number=> @number, :direction => 'Outboundcall', :time => Time.now.to_i)
 
end
end

but call end reason does not reflect actual call status. for instance, call is answered & hangup - status is hangup and also call ring but no answer - status is same hangup with same end_event plateform_code.  

If you want to track all events in a call's lifetime, you should build this state machine yourself. You have, in addition to on_end, on_answer, on_joined and on_unjoined. You could use these events to progressively build your CDR. Alternatively, from on_end you could look at Call#start_time (http://www.rubydoc.info/gems/adhearsion/Adhearsion/Call#start_time-instance_method) which is defined as the time at which the call was answered. If the call was not answered, this would be nil.
 
if we can link call id with CDR  of asterisk by setting asterisk variable. then all problem will be resolved. There is a adhearsion-asterisk gem and it can set_variable from call controller. Is there any way to set variable from outside of call controller? Call controller only execute when call is answered  and we can not link if call is failed.  Something like :

require 'adhearsion-asterisk'
class
MakeOutboundCall
  attr_accessor :id, :number
  def initialize(id,number)
   
@id=id
    @number=number
    @call_id='assigned number'
  end

  def call_start!
    call = Adhearsion::OutboundCall.new
    call.execute_controller_or_router_on_answer NoticeBoardCallController, {:id => @id, :initiate_from => 'outbound'}
   
call.on_end do |end_event|
      end
      status=Cdr.find_by(:userfield => call.id).status
     
log_info=NoticeboardLog.find_by(:call_id => call.id)
      log_info.update(:status=> status)
   end
   
call.dial "SIP/#{@number}", :from => @call_id
    NoticeboardLog.create(:call_id => call.id, :noticeboard_id => @id,:outbound_retried=> 0,:phone_number=> @number, :direction => 'Outboundcall', :time => Time.now.to_i)
   
set_variable('CDR(userfield)',call.id))
 
end
end

but set_variable is controller method so it cause error. Is there any way to link or find right call status for each and individual call for now?

I m thinking to little  customize outboundCall class to achieve call status. 
 

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Adhearsion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.