Autodialler API Protocol
The Patriot desktop client can implement this protocol by acting as either a websocket server or client. This is controlled by which module you have registered: WebsocketClientDialler (Patriot as Client) or DesktopApiDialler (Patriot as Server).
:::tip Recommended: Patriot as Client
Integrating with Patriot acting as the websocket client is the recommended approach. These integrations will be compatible with both the Patriot web client (ICA) and the Patriot Windows desktop client.
:::
- Patriot as Client
- Patriot as Server
In this mode Patriot connects out to your Dialler Bridge server. The bridge translates Patriot API messages into commands for your phone system.
In this mode Patriot hosts a local websocket server that your Dialler Client application connects to directly.
Configuration
- Patriot as Client
- Patriot as Server
The following settings are configured in the Patriot Client .config file (typically PatriotMVVM.exe.config):
| Setting | Value |
|---|---|
DiallerType | WebsocketClient |
WebSocketClientDiallerUrl | WebSocket URL of your Dialler Bridge server (e.g. wss://bridge.example.com/dialler) |
WebSocketClientDiallerConfig | JSON string passed as the payload of the InitRequest — typically contains authentication credentials required by your bridge |
Example .config snippet:
<setting name="DiallerType" serializeAs="String">
<value>WebsocketClient</value>
</setting>
<setting name="WebSocketClientDiallerUrl" serializeAs="String">
<value>wss://bridge.example.com/dialler</value>
</setting>
<setting name="WebSocketClientDiallerConfig" serializeAs="String">
<value>{"userName": "123456", "password": "ABC123DEF456"}</value>
</setting>
For secure connections (wss://) the Dialler Bridge server's certificate must be trusted by the Patriot client machine.
The following settings are configured in the Patriot Client .config file:
| Setting | Value |
|---|---|
WebSocketServerPort | Port for the local WebSocket server (default: 9009) |
WebSocketApiKey | API key that the Dialler Client must supply in its AuthenticationRequest |
Connection Setup
- Patriot as Client
- Patriot as Server
The Patriot Client connects out to a Dialler Server implementing this API.
Initialization / Authentication
Once connected, Patriot sends an InitRequest containing server-specific configuration in JSON format, set via the WebSocketClientDiallerConfig setting in the Patriot Client .config file.
The Dialler Server must respond with an InitResponse indicating whether initialization was successful.
- If no response is received within 30 seconds, Patriot re-sends the InitRequest.
- If the connection is broken, Patriot automatically reconnects and re-sends the InitRequest.
Patriot also sends a Heartbeat message every 5 seconds. The Dialler Server should respond with a HeartbeatResponse to confirm the connection is healthy.
The Patriot Desktop Client hosts a websocket server at:
wss://desktop-client-api.patriotsystems.com:<port-number>/ws/dialler/v1
A public DNS record directs desktop-client-api.patriotsystems.com to 127.0.0.1 (localhost). If a public DNS lookup is not suitable, configure a DNS record in a local network DNS server or via the Windows HOSTS file.
Patriot automatically generates a self-signed SSL certificate and prompts users to add it to their personal Trusted Root Certificates store.
The port-number defaults to 9009 but can be configured with the WebSocketServerPort setting in the Patriot Client .config file.
Authentication
Once connected, the Dialler Client must send an AuthenticationRequest containing a valid ApiKey. Patriot responds with an AuthenticationResponse.
Until a valid AuthenticationResponse has been received, Patriot will ignore any non-AuthenticationRequest messages.
Message Definitions
Connection Messages
- Patriot as Client
- Patriot as Server
InitRequest
Sent from Patriot to Dialler Server to upgrade to an initialized (authenticated) socket.
interface InitRequest {
type: 'init-request';
payload: {
/**
* Server specific
*/
};
}
Example
{
"type": "init-request",
"payload": {
"userName": "123456",
"password": "ABC123DEF456"
}
}
InitResponse
Sent from Dialler Server to Patriot to acknowledge an Init Request.
interface InitResponse {
type: 'init-response';
payload: {
success: boolean;
error?: string;
};
}
Example
{
"type": "init-response",
"payload": {
"success": true
}
}
Heartbeat
Sent from Patriot to Dialler Server every five seconds to test the connection status.
interface Heartbeat {
type: 'heartbeat';
}
Example
{
"type": "heartbeat"
}
Heartbeat Response
Sent from Dialler Server to Patriot to acknowledge a Heartbeat and confirm the connection status is normal.
interface HeartbeatResponse {
type: 'heartbeat-response';
}
Example
{
"type": "heartbeat-response"
}
AuthenticationRequest
Sent from Dialler Client to Patriot to upgrade to an authenticated socket.
interface AuthenticationRequest {
type: 'authentication-request';
payload: {
/**
* Optional. If specified then the corresponding AuthenticationResponse will include this requestId.
*/
requestId?: string;
apiKey: string;
};
}
Example
{
"type": "authentication-request",
"payload": {
"requestId": "123456",
"apiKey": "ABC123DEF456"
}
}
AuthenticationResponse
Sent from Patriot to Dialler Client to acknowledge an Authentication Request.
interface AuthenticationResponse {
type: 'authentication-response';
payload: {
/**
* requestId from the corresponding AuthenticationRequest message.
*/
requestId: string;
success: boolean;
error?: string;
};
}
Example
{
"type": "authentication-response",
"payload": {
"requestId": "123456",
"success": true
}
}
Call Control Messages
These messages apply to both integration modes.
DialRequest
Sent from Patriot to Dialler to request an outgoing call to be initiated.
interface DialRequest {
type: 'dial-request';
payload: {
// The phone number to dial.
// NOTE: this is a sanitised version of the user entered phone
// number and will include only the characters 0-9, '+', '*' and '#'.
phoneNo: string;
// The raw user entered phone number
rawPhoneNo: string;
};
}
Example
{
"type": "dial-request",
"payload": {
"phoneNo": "+0123456789",
"rawPhoneNo": "+01 (2) 3-456-789"
}
}
HangupRequest
Sent from Patriot to Dialler to request the current call to be ended.
interface HangupRequest {
type: 'hangup-request';
}
Example
{
"type": "hangup-request"
}
CallStatusRequest
Sent from Patriot to Dialler to request a Call Status Update (see CallStatusUpdate).
interface CallStatusRequest {
type: 'call-status-request';
}
Example
{
"type": "call-status-request"
}
CallStatusUpdate
Sent from Dialler to Patriot to inform of Call Status Updates. This should be sent on status changes as well as in response to CallStatusRequest messages.
interface CallStatusUpdate {
type: 'call-status-update';
payload: {
callActive: boolean;
outbound?: boolean;
callerId?: string;
};
}
Example
{
"type": "call-status-update",
"payload": {
"callActive": true,
"outbound": true,
"callerId": "123-456-789"
}
}