๐ค Basics
Here is a look at how the migration process would look for you if you choose to migrate from Twilio to Ospi
Creating a Roomโ
Intuitively, a Room represents a virtual space where end-users communicate
โ Twilio Docs
The equivalent of โRoomsโ from Twilio in Ospi is โMeetingsโ.
-
In Twilio you create a room by calling the REST API https://www.twilio.com/docs/video/api/rooms-resource (or using a client library)
-
In Ospi you create a meeting by calling a similar REST API https://docs.ospi-international.org//api#/operations/create_meeting
Request
- You pass a
UniqueNamewhile creating a Room in Twilio There is no UniqueName equivalent in Ospi, you can optionally pass thetitleof meeting if want - If you want the recording to start when participants join you use
RecordParticipantsOnConnectwhile creating a Room The equivalent parameter in Ospi isrecord_on_start MediaRegionโgllโ is the default where Twilio decides the best region. In Ospi if you don't pass any region inpreferred_regionOspi selects the best region automatically
Response
- In the response you get a
room_sidin Twilio, you get ameeting_idin Ospi
| Twilio | Ospi |
|---|---|
| Room | Meeting |
| Room SID | Meeting ID |
Generating the participant tokenโ
With Twilio you generate the JWT for the user on your own https://www.twilio.com/docs/video/tutorials/user-identity-access-tokens
const token = new AccessToken(twilioAccountSid, twilioApiKey, twilioApiSecret, {
identity: identity,
});
token.addGrant(videoGrant);
console.log(token.toJwt());
In Ospi, you make a REST API call to Add Participant API which returns authToken.
| Twilio | Ospi |
|---|---|
| Access Token | Authtoken |
Installationโ
Install the Ospi SDK.
npm install @dytesdk/web-core
If you are using CDN / script tags install using
<script src="https://cdn.dyte.in/core/dyte.js" />
Now you can remove the Twilio SDK from your project by uninstalling the package.
npm uninstall twilio-video
Or if using the Twilio CDN script, remove the relevant script tag
Joining a Roomโ
Twilio
import * as TwilioVideo from 'twilio-video';
twilioRoom = await TwilioVideo.connect(TOKEN, {
name: 'yourName',
audio: false,
video: false,
dominantSpeaker: true,
});
Ospi
import DyteClient from '@dytesdk/web-core';
meeting = await DyteClient.init({ authToken: TOKEN });
await meeting.join();
Let's look at media next