call_center 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -20,7 +20,7 @@ Terminology
20
20
  -----------
21
21
 
22
22
  * **Call** - An application resource of yours that encapsulates a phone call. Phone calls are then acted on: answered, transferred, declined, etc.
23
- * **Event** - Is something that happens outside or inside your application in relation to a **Call**. Someone picks up, hangs up, presses a button, etc.
23
+ * **Event** - Is something that happens outside or inside your application in relation to a **Call**. Someone picks up, hangs up, presses a button, etc. But overall, it's anything that can be triggered by Twilio callbacks.
24
24
  * **State** - Is the status a **Call** is in which is descriptive of what's happened so far and what are the next things that should happen. (e.g. a call on hold is waiting for the agent to return)
25
25
  * **CallFlow** - Is a definition of the process a **Call** goes through. **Events** drive the flow between **States**. (e.g. a simple workflow is when noone answers the call, send the call to voicemail)
26
26
  * **Render** - Is the ability of the **CallFlow** to return TwiML to bring the call into the **State** or modify the live call through a **Redirect**.
@@ -56,7 +56,7 @@ Usage
56
56
  end
57
57
  end
58
58
 
59
- Benefits of **CallCenter** is that it's backed by [state_machine](https://github.com/pluginaweek/state_machine). Which means you can interact with events the same you do in state_machine.
59
+ Benefits of **CallCenter** is that it's backed by [state_machine](https://github.com/pluginaweek/state_machine). Which means you can interact with events the same you do in `state_machine`.
60
60
 
61
61
  @call.incoming_call!
62
62
  @call.voicemail?
@@ -79,6 +79,18 @@ The general application flow for a **CallFlow** is like this:
79
79
  * You respond by rendering TwiML. Your TwiML contains callbacks to events or redirects
80
80
  3. Repeat 2.
81
81
 
82
+ In order to DRY up the callbacks, it is best to have use standardized callback URLs. A handy concept is the `flow_url`, which follows the pattern:
83
+
84
+ http://domain.com/calls/flow?call_id=?&event=?
85
+
86
+ By handling this in your controller, you can immediately retrieve the **Call** from persistence, run an event on the call, and return the rendered TwiML. Here's an example:
87
+
88
+ def flow
89
+ render :xml => @call.run(params[:event])
90
+ end
91
+
92
+ For an in-depth example, take a look at [call_roulette](https://github.com/zendesk/call_roulette).
93
+
82
94
  Rendering
83
95
  ---------
84
96
 
@@ -86,12 +98,12 @@ Rendering is your way of interacting with Twilio. Thus, it provides two faciliti
86
98
 
87
99
  on_render(:sales) do |the_call, xml_builder|
88
100
  xml_builder.Say "This is Sales!"
89
-
101
+
90
102
  the_call.flag! # You can access the call explicitly
91
103
  flag! # Or access it implicitly
92
104
  end
93
105
 
94
- Renders:
106
+ Renders with `@call.render` if the current state is :sales:
95
107
 
96
108
  <?xml version="1.0" encoding="UTF-8"?>
97
109
  <Response>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/call_center.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{call_center}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Henry Hsu"]
12
- s.date = %q{2011-09-21}
12
+ s.date = %q{2011-09-29}
13
13
  s.description = %q{Support for describing call center workflows}
14
14
  s.email = %q{hhsu@zendesk.com}
15
15
  s.extra_rdoc_files = [
@@ -2,6 +2,7 @@ module CallCenter
2
2
  module Test
3
3
  module DSL
4
4
  def self.included(base)
5
+ base.send(:include, ActionController::Assertions::SelectorAssertions)
5
6
  base.extend(ClassMethods)
6
7
  base.class_eval do
7
8
  def response_from_page_or_rjs_with_body
@@ -21,7 +22,7 @@ module CallCenter
21
22
  event = options.delete(:on)
22
23
  setup_block = options.delete(:when)
23
24
  setup_block_line = setup_block.to_s.match(/.*@(.*):([0-9]+)>/)[2] if setup_block
24
- state_field = options.delete(:state) || :state
25
+ state_field = self.call_center_state_field || options.delete(:state) || :state
25
26
  from, to = options.to_a.first
26
27
  description = ":#{from} => :#{to} via #{event}!#{setup_block_line.present? ? " when:#{setup_block_line}" : nil}"
27
28
  context "" do
@@ -47,6 +48,10 @@ module CallCenter
47
48
  end
48
49
  end
49
50
 
51
+ def call_center_state_field(field = nil)
52
+ field.nil? ? @_call_center_state_field : (@_call_center_state_field = field)
53
+ end
54
+
50
55
  def should_also(&block)
51
56
  line = block.to_s.match(/.*@(.*):([0-9]+)>/)[2]
52
57
  should "also satisfy block on line #{line}" do
data/test/helper.rb CHANGED
@@ -20,8 +20,6 @@ require 'active_support'
20
20
  require 'action_pack'
21
21
  require 'action_controller'
22
22
  class Test::Unit::TestCase
23
- include ActionController::Assertions::SelectorAssertions
24
-
25
23
  def response_from_page_or_rjs
26
24
  HTML::Document.new(@body).root
27
25
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: call_center
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henry Hsu
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-21 00:00:00 -07:00
18
+ date: 2011-09-29 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency