PHPおよびLaravelを使用したウォーム転送
Have you ever been disconnected from a support call while being transferred to someone else? That couldn't have left a great impression on you...
Warm transfer eliminates this problem - it allows your agents to have the ability to dial in another agent in real time.
Today we'll add warm transfer to a PHP and Laravel application so we can engender warm feelings among customers talking to support.
このマーケティング通知が高レベルでどのように機能するのかを以下に示します。
- The first agent becomes available by connecting through the web client.
- The second agent becomes available by connecting through the web client.
- A customer calls our support line.
- クライアントは、最初の担当者が電話に応対するまでしばらく待ちます。
- While the first agent is on the phone with the client, he or she dials the second agent into the call.
- Once the second agent is on the call, the first one can disconnect. The client and the second agent stay on the call.
さぁ、はじめましょう! GitHubからサンプルアプリケーションをクローンし、下のボタンをクリックして始めてください。
音声通話Webhookのセットアップ
First, let's configure the voice web-hook for the Twilio number that customers will dial when they want to talk to a support agent.
This should be the public-facing URL for your app in production.
One option to expose a development URL from your local machine is to use ngrok. Your URL would then be something like:
https://<your-ngrok-id>.ngrok.io/conference/connect/client
Great work! Webhook in place, we're ready to start looking at the code.
Connect an Agent to a Call
Here you can see all front-end code necessary to connect an agent using Twilio's Voice Web Client.
We need three things to have a live web client:
- ケイパビリティートークン(Laravel アプリから提供)
- 担当者ごとの一意の識別子(文字列)
- Twilio によってトリガーされる各種イベントを処理するためのイベントリスナー
次のステップでは、ケイパビリティートークンの生成についてもう少し詳しく見てみましょう。
ケイパビリティートークンを生成する
Twilio 音声通話 Web クライアントに接続するために、ケイパビリティートークンが必要です。
Webクライアントを通じた着信接続を許可するには、トークンの生成時に識別子が提供される必要があります。
Next we'll look at handling incoming calls.
着信通話のハンドリング
For this tutorial we used fixed identifier strings like agent1
and agent2
but you can use any unique string for your call center clients. These identifiers will be used to create outbound calls to the specified agent through the Twilio REST API.
When a client makes a call to our Twilio number ,the application receives a POST request asking for instructions. We use TwiML to instruct the client to join a conference room and use the Twilio REST API client to invite (and start a call with) the first agent.
When providing instructions to the client, we also provide a waitUrl
. This URL is another end point of our application and will return more TwiML to SAY welcome to the user and also PLAY some music while on hold.
We use the client's CallSid
as the conference identifier. Since all participants need this identifier to join the conference, we'll need to store it in a database so that we can grab it when we dial the second agent into the conference.
Next let's look at the TwiML response of our application.
Provide TwiML Instruction To The Client
Here we create a TwiMLResponse
that will contain a DIAL
verb with a CONFERENCE
noun that will instruct the JavaScript client to join a specific conference room.
Next let's see how to dial the first agent into the call.
Dial The First Agent Into the Call
アプリに対し、担当者へのダイヤリングを処理する createCall
メソッドを作成しました。このメソッドでは、Twilio の REST API を使用して新しい通話を作成します。create
メソッドは以下のパラメーターを受け取ります。
from
:Twilio 電話番号to
:担当者の Web クライアント識別子(agent1
またはagent2
)url
:通話が接続したときに TwiML 命令を求める URL
担当者が Web クライアントで通話に応答すると、コールバック URL に対するリクエストが作成され、クライアントがすでに待機しているカンファレンスに参加するようこの通話に指示が出されます。
Let's look at bringing agent #2 into the call next.
Dial the Second Agent Into the Call
顧客と最初の担当者が通話中のとき、次の担当者へのウォーム転送を行う準備はすでに完了しています。
The first agent makes a request passing its agentId.
We look for the conferenceId
needed so we can connect the second agent. Since we already have a createCall
method, we can simply use that to invite the second agent.
Coming up next: letting the first agent leave the support call so the second can take over.
最初の担当者が通話から抜ける
When the three participants have joined the same call, the first agent has served his or her purpose. Now agent #1 can drop the call, leaving agent #2 and the client to discuss the weather and important matters of support.
It is important to notice the differences between the TwiML each one of the participants received when joining the call:
- Both agent one and two have
startConferenceOnEnter
set totrue
. - For the client calling and for agent two,
endConferenceOnExit
is set totrue
.
Translated, this means a conference will start when either agent joins the call. It also means the client or agent #2 disconnecting will hang up the call.
And that's a wrap! Thank you for helping us add warm transfers so our support staff can tag in other agents for help.
Next we'll look at some other awesome features Twilio makes easy to add.
次はどこでしょうか?
We love PHP here at Twilio and have a lot of great content on the site. Alas, we're going to suggest just two other pieces at this point:
もう 1 つのサーバー停止状態も見逃さないでください。サーバー停止状態が発生した場合に SMS 経由ですべての管理者に警告するサーバー通知システムを構築する方法を学びます。
Cut down on the no-shows by implementing automatic appointment reminders for your clients.
これは役に立ちましたか?
このチュートリアルをお読みいただき、ありがとうございます。 どんなものを構築されたか(されるのか)、ぜひTwitterでお知らせください。
ヘルプが必要ですか?
誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。