@withdialer/node
v0.1.1
Published
Dialer backend middleware — mints agent tokens for the React SDK
Downloads
195
Maintainers
Readme
@withdialer/node
The power dialer built for developers. Backend middleware that mints agent tokens for the React SDK.
Install
npm install @withdialer/nodeUsage
import express from "express";
import { DialerAuth } from "@withdialer/node";
const app = express();
app.use(
DialerAuth({
apiKey: process.env.DIALER_API_KEY,
getAgentId: (req) => req.user.id,
})
);
app.listen(3000);This creates a POST /dialer-auth endpoint. The React SDK calls it automatically to get short-lived agent tokens.
Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| apiKey | string | required | Your sk_live_... API key |
| getAgentId | (req) => string | required | Return the current user's member ID |
| path | string | "/dialer-auth" | Endpoint path |
| expiresIn | number | 3600 | Token TTL in seconds |
| baseUrl | string | "https://api.withdialer.com" | API base URL |
Pair with the React SDK
npm install @withdialer/reactimport { useDialer, CallCard } from "@withdialer/react";
function Agent() {
const { activeCall, endCall } = useDialer({ authUrl: "/dialer-auth" });
return activeCall
? <CallCard call={activeCall} onEnd={endCall} />
: <div>Waiting for a call...</div>;
}