Skip to content

Commit c22d431

Browse files
authored
Merge pull request #8 from Vonage-Community/Add_Voice_Functionality
Add voice functionality
2 parents acb52f1 + 05a682c commit c22d431

File tree

10 files changed

+71
-5
lines changed

10 files changed

+71
-5
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# app/controllers/call_events_controller.rb
2+
class CallEventsController < ApplicationController
3+
# We disable CSRF for this webhook call
4+
skip_before_action :verify_authenticity_token
5+
6+
def create
7+
if params[:uuid]
8+
Call.where(uuid: params[:uuid])
9+
.first_or_create
10+
.update(
11+
status: params[:status],
12+
conversation_uuid: params[:conversation_uuid]
13+
)
14+
end
15+
16+
head :ok
17+
end
18+
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# app/controllers/inbound_calls_controller.rb
2+
class InboundCallsController < ApplicationController
3+
# We disable CSRF for this webhook call
4+
skip_before_action :verify_authenticity_token
5+
6+
def create
7+
Call.where(conversation_uuid: params[:conversation_uuid])
8+
.first_or_create
9+
.update(
10+
to: params[:to],
11+
from: params[:from],
12+
uuid: params[:uuid],
13+
conversation_uuid: params[:conversation_uuid],
14+
is_inbound: true
15+
16+
)
17+
18+
render json: [
19+
{
20+
action: 'talk',
21+
voiceName: 'Jennifer',
22+
text: 'Hello, thank you for calling. This is Jennifer from Vonage. Ciao.'
23+
}
24+
]
25+
end
26+
end

app/helpers/call_events_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module CallEventsHelper
2+
end

app/helpers/inbound_calls_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module InboundCallsHelper
2+
end

app/views/inbound_sms/create.html.erb

Lines changed: 0 additions & 2 deletions
This file was deleted.

app/views/sms_message_status/create.html.erb

Lines changed: 0 additions & 2 deletions
This file was deleted.

config/credentials.yml.enc

Lines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65GADRbzUyAQfOygR8KCEAk1UW0s3V3TeLOA72amiY--oHceahh7YS8vvw8m--Vfr3zSnGh6xNf+gYox+lzw==

config/routes.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@
1212

1313
# For OutboundCall controller, new & create & show
1414
resources :outbound_calls, only: [:new, :create, :show]
15+
16+
# For CallEvents controller, create
17+
resources :call_events, only: [:create]
18+
19+
# For InboundCalls controller, create
20+
resources :inbound_calls, only: [:create]
1521
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "test_helper"
2+
3+
class CallEventsControllerTest < ActionDispatch::IntegrationTest
4+
test "should get create" do
5+
get call_events_create_url
6+
assert_response :success
7+
end
8+
end
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
require "test_helper"
2+
3+
class InboundCallsControllerTest < ActionDispatch::IntegrationTest
4+
test "should get create" do
5+
get inbound_calls_create_url
6+
assert_response :success
7+
end
8+
end

0 commit comments

Comments
 (0)