Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 4a3f32f

Browse files
author
Sarah Stringer
committed
Add another VirtualAgent code sample.
1 parent 3401a09 commit 4a3f32f

File tree

8 files changed

+89
-0
lines changed

8 files changed

+89
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Response>
3+
<Say>Hello! You will be now be connected to a virtual agent.</Say>
4+
<Connect action="https://myactionurl.com/virtualagent_ended">
5+
<VirtualAgent connectorName="project" statusCallback="https://mycallbackurl.com"/>
6+
</Connect>
7+
</Response>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const VoiceResponse = require('twilio').twiml.VoiceResponse;
2+
3+
const response = new VoiceResponse();
4+
response.say('Hello! You will be now be connected to a virtual agent.');
5+
const connect = response.connect({
6+
action: 'https://myactionurl.com/virtualagent_ended'
7+
});
8+
connect.virtualAgent({
9+
connectorName: 'project',
10+
statusCallback: 'https://mycallbackurl.com'
11+
});
12+
13+
console.log(response.toString());
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using Twilio.TwiML;
3+
using Twilio.TwiML.Voice;
4+
5+
6+
class Example
7+
{
8+
static void Main()
9+
{
10+
var response = new VoiceResponse();
11+
response.Say("Hello! You will be now be connected to a virtual agent.");
12+
var connect = new Connect(action: new Uri("https://myactionurl.com/virtualagent_ended"));
13+
connect.VirtualAgent(connectorName: "project", statusCallback: "https://mycallbackurl.com");
14+
response.Append(connect);
15+
16+
Console.WriteLine(response.ToString());
17+
}
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
require_once './vendor/autoload.php';
3+
use Twilio\TwiML\VoiceResponse;
4+
5+
$response = new VoiceResponse();
6+
$response->say('Hello! You will be now be connected to a virtual agent.');
7+
$connect = $response->connect(['action' => 'https://myactionurl.com/virtualagent_ended']);
8+
$connect->virtualagent(['connectorName' => 'project', 'statusCallback' => 'https://mycallbackurl.com']);
9+
10+
echo $response;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'twilio-ruby'
2+
3+
response = Twilio::TwiML::VoiceResponse.new
4+
response.say(message: 'Hello! You will be now be connected to a virtual agent.')
5+
response.connect(action: 'https://myactionurl.com/virtualagent_ended') do |connect|
6+
connect.virtual_agent(connector_name: 'project', status_callback: 'https://mycallbackurl.com')
7+
end
8+
9+
puts response
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from twilio.twiml.voice_response import Connect, VoiceResponse, Say, VirtualAgent
2+
3+
response = VoiceResponse()
4+
response.say('Hello! You will be now be connected to a virtual agent.')
5+
connect = Connect(action='https://myactionurl.com/virtualagent_ended')
6+
connect.virtualagent(
7+
connector_name='project', status_callback='https://mycallbackurl.com'
8+
)
9+
response.append(connect)
10+
11+
print(response)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import com.twilio.twiml.voice.Connect;
2+
import com.twilio.twiml.VoiceResponse;
3+
import com.twilio.twiml.voice.Say;
4+
import com.twilio.twiml.voice.VirtualAgent;
5+
import com.twilio.twiml.TwiMLException;
6+
7+
8+
public class Example {
9+
public static void main(String[] args) {
10+
Say say = new Say.Builder("Hello! You will be now be connected to a virtual agent.").build();
11+
VirtualAgent virtualagent = new VirtualAgent.Builder().connectorName("project").statusCallback("https://mycallbackurl.com").build();
12+
Connect connect = new Connect.Builder().action("https://myactionurl.com/virtualagent_ended").virtualAgent(virtualagent).build();
13+
VoiceResponse response = new VoiceResponse.Builder().say(say).connect(connect).build();
14+
15+
try {
16+
System.out.println(response.toXml());
17+
} catch (TwiMLException e) {
18+
e.printStackTrace();
19+
}
20+
}
21+
}

twiml/voice/connect/virtualagent/output/basic.twiml renamed to twiml/voice/connect/virtualagent/output/connect_virtualagent.twiml

File renamed without changes.

0 commit comments

Comments
 (0)