Skip to content

Commit 5ebf521

Browse files
committed
Added Inbound Call Functionality
1 parent ccfc8af commit 5ebf521

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed
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/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
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>InboundCalls#create</h1>
2+
<p>Find me in app/views/inbound_calls/create.html.erb</p>

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Rails.application.routes.draw do
2+
get "inbound_calls/create"
23

34
# For OutboundSms controller, new & create
45
get '/outbound_sms/new', to: 'outbound_sms#new', as: :new_outbound_sms
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)