Search code examples
javasipopentoktokboxplivo

Unclear how to connect Plivo to OpenTok Java SDK SIP


I'm trying to use Plivo with the OpenTok Java SDK to dial out. There is an example for javascript where Plivo is used.

I'm able to invoke the method Openok.dial() and get a positive response that I then send to my react client.

There are no errors but I'm not calling the targeted number.

I'm not understanding how to use the uris or if they are still necessary.

So is it still necessary to create the uri's as stated in the JS example (https://github.com/opentok/opentok-sip-samples/tree/master/Plivo-SIP-Dial-Out)? And how do i then use those uri's?

Or is there an example i can peek to get a rough idea?


Solution

  • TokBox Developer Evangelist here.

    The OpenTok SIP Interconnect feature allows you dial out to a SIP address (uri). With the Plivo sample, you would have to create an application on their website and configure the Plivo application with the appropriate webhooks so when that when you dial out to the Plivo SIP uri from OpenTok, you will get events on the webhook which will allow you to connect the OpenTok session with the PSTN user.

    You can also leverage Nexmo or other SIP providers to dial out and connect an OpenTok session with a PSTN user. For example, if you use Nexmo, you can dial directly to a phone number by constructing the SIP properties in the OpenTok Java SDK like so:

    String nexmoApiKey = "";
    String nexmoApiSecret = "";
    String sessionId = "";
    String token = "";
    SipProperties properties = new SipProperties.Builder()
         .sipUri("sip:[email protected]")
         .from("[email protected]")
         .headersJsonStartingWithXDash(headerJson)
         .userName(nexmoApiKey)
         .password(nexmoApiSecret)
         .secure(false)
         .build();
     Sip sip = opentok.dial(sessionId, token, properties);
    

    Please note that you would have to configure the phoneNumber, sessionId, token, and credentials - I've just added a sample number along with empty strings as the credentials.