Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The reference components demonstrate several common Twilio Voice use cases. Thes
- View quality metrics
- Receive warnings
- View errors
- Voice AI Assistant
- Voice AI Conversation
- Place an outbound call and connect to an agent
- Provide a Websocket server to interface with Conversation Relay
- Basic OpenAI integration
Expand Down Expand Up @@ -51,7 +51,7 @@ cp example.env .env
https://yourdomain/twilio-voice-dialer/twiml
https://yourdomain/twilio-voice-basic-call-control/twiml
https://yourdomain/twilio-voice-monitoring/twiml
https://yourdomain/twilio-voice-ai-assistant/twiml
https://yourdomain/twilio-voice-ai-conversation/twiml
```

## Run the project locally
Expand All @@ -67,4 +67,4 @@ npm start
- Dialer: [http://localhost:3030/twilio-voice-dialer?identity=bob](http://localhost:3030/twilio-voice-dialer?identity=bob).
- Basic Call Control: [http://localhost:3030/twilio-voice-basic-call-control?identity=bob](http://localhost:3030/twilio-voice-basic-call-control?identity=bob).
- Monitoring: [http://localhost:3030/twilio-voice-monitoring?identity=bob](http://localhost:3030/twilio-voice-monitoring?identity=bob).
- Voice AI Assistant: [http://localhost:3030/twilio-voice-ai-assistant?identity=bob](http://localhost:3030/twilio-voice-ai-assistant?identity=bob).
- Voice AI Conversation: [http://localhost:3030/twilio-voice-ai-conversation?identity=bob](http://localhost:3030/twilio-voice-ai-conversation?identity=bob).
2 changes: 1 addition & 1 deletion example.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ CALLBACK_BASE_URL=foo.ngrok.dev
# Default identity to use
DEFAULT_IDENTITY=alice

# twilio-voice-ai-assistant
# twilio-voice-ai-conversation
# See https://platform.openai.com/settings/organization/api-keys
OPENAI_API_KEY=sk-proj.......
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Twilio Voice AI Assistant</title>
<title>Twilio Voice AI Conversation</title>
</head>
<body>
<h1>Twilio Voice AI Assistant</h1>
<h1>Twilio Voice AI Conversation</h1>

<twilio-voice-ai-assistant></twilio-voice-ai-assistant>
<twilio-voice-ai-conversation></twilio-voice-ai-conversation>

<script src="/twilio.js"></script>
<script src="twilio-voice-ai-assistant.js"></script>
<script src="twilio-voice-ai-conversation.js"></script>
<script src="index.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
(async function() {
const urlParams = new URLSearchParams(window.location.search);
const identity = urlParams.get('identity');
const tokenUrl = `/twilio-voice-ai-assistant/token?identity=${identity}`;
const tokenUrl = `/twilio-voice-ai-conversation/token?identity=${identity}`;

const response = await fetch(tokenUrl);
const data = await response.json();

const twilioVoiceAIAssistant = document.querySelector('twilio-voice-ai-assistant');
twilioVoiceAIAssistant.setToken(data.token);
twilioVoiceAIAssistant.addEventListener('tokenWillExpire', async (e) => {
const twilioVoiceAIConversation = document.querySelector('twilio-voice-ai-conversation');
twilioVoiceAIConversation.setToken(data.token);
twilioVoiceAIConversation.addEventListener('tokenWillExpire', async (e) => {
const device = e.detail.device;

const updateTokenResponse = await fetch(tokenUrl);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TwilioVoiceAIAssistant extends HTMLElement {
class TwilioVoiceAIConversation extends HTMLElement {
#call;
#conversationRelayLog;
#device;
Expand Down Expand Up @@ -114,6 +114,6 @@ class TwilioVoiceAIAssistant extends HTMLElement {
}

customElements.define(
'twilio-voice-ai-assistant',
TwilioVoiceAIAssistant
'twilio-voice-ai-conversation',
TwilioVoiceAIConversation
);
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ class TwilioVoiceDialer extends HTMLElement {
this.dispatchEvent(tokenWillExpireEvent);
}

disconnectedCallback() {
this.#device.destroy();
}

#handleAccept() {
this.#call.accept();
this.#setStatus('inprogress');
Expand Down