agent-1001).1234567891011import { RuutVoice } from "@ruut/voice-sdk"; const client = new RuutVoice({ accountSid, authToken, baseUrl }); // Create + fetch credentials in one call const creds = await client.agentExtensions.provision({ agentName: "Adaeze", }); console.log(creds.username, creds.password, creds.ws_url); // agent-1001 ******** wss://voice.ruut.chat:8443
12const ext = await client.agentExtensions.create({ agentName: "Adaeze" }); const creds = await client.agentExtensions.credentials(ext.sid);
expires_at, re-fetch or rotate credentials as needed, and do not assume every extension has a default expiry.agentExtensions.credentials() result also contains restAuthToken, restAccountSid, and restBaseUrl. Do not return the full object to a browser. Return only the SIP credentials and WebSocket URL to an authenticated user. Set autoPresence: false and update presence through your own authenticated server endpoint; the default auto-presence implementation requires REST credentials in the browser.@ruut/voice-sdk/browser) to register and answer calls:import { RuutDevice } from "@ruut/voice-sdk/browser"; const device = new RuutDevice({ credentials: { username: creds.username, password: creds.password, domain: creds.domain, wsUrl: creds.ws_url, }, autoPresence: false, // Keep the account Auth Token on your server. audioElement: document.querySelector("audio"), }); device.on("registered", () => console.log("Ready to take calls")); device.on("incoming", (call) => { // Show an Answer button, then: call.accept(); }); device.on("callEnded", () => console.log("Call ended")); await device.start();
online and registered to be dialed.<Dial> with the agent's SIP URI:123<Response> <Dial>sip:agent-1001@sip.ruut.chat</Dial> </Response>
123456await client.calls.createAgentCall({ agentUsername: "agent-1001", sipDomain: "sip.ruut.chat", from: "+2348000000002", twiml: new VoiceResponse().say("Connecting you to an agent.").toXml(), });
1await client.agentExtensions.update("AE…", { status: "online", ttlSeconds: 3600 });
online, offline, busy, away, dnd.