Skip to main content
useDialOut(params?): Object Tracks the state of dial-out sessions and returns helper functions that wrap the daily-js dial-out, DTMF and SIP transfer methods. Accepts optional callbacks for the dial-out events. Dial-out state is tracked per session, keyed by sessionId. State is reset when the local participant leaves the meeting or the call instance is destroyed.
Dial-out requires a paid Daily account, dial-out approval, and enable_dialout set on the room. See the Dial-in and dial-out guide for setup and requirements.

Parameters

onDialOutConnected
Function
Callback for the dialout-connected event.
onDialOutAnswered
Function
Callback for the dialout-answered event.
onDialOutStopped
Function
Callback for the dialout-stopped event.
onDialOutError
Function
Callback for the dialout-error event.
onDialOutWarning
Function
Callback for the dialout-warning event.

Return value

Returns an object with the following properties:
sessions
Object
A map of active dial-out sessions, keyed by sessionId.
startDialOut
Function
Wraps daily-js startDialOut().
stopDialOut
Function
Wraps daily-js stopDialOut().
sendDTMF
Function
Wraps daily-js sendDTMF().
sipCallTransfer
Function
Wraps daily-js sipCallTransfer().
sipRefer
Function
Wraps daily-js sipRefer().
A dialout-error or dialout-warning that arrives before a session is established (with no sessionId) is delivered through the onDialOutError / onDialOutWarning callbacks, but is not added to sessions.

Example

import { useDialOut } from '@daily-co/daily-react';

export const DialOutDemo = () => {
  const { sessions, startDialOut, stopDialOut, sendDTMF } = useDialOut({
    onDialOutError: (ev) => console.error('Dial-out failed', ev.errorMsg),
  });

  const callSupport = () =>
    startDialOut({ phoneNumber: '+15551234567' });

  return (
    <div>
      <button onClick={callSupport}>Call support</button>
      {Object.values(sessions).map((session) => (
        <div key={session.sessionId}>
          <span>
            {session.sessionId}: {session.status}
          </span>
          <button
            onClick={() =>
              sendDTMF({ sessionId: session.sessionId, tones: '1' })
            }
          >
            Press 1
          </button>
          <button onClick={() => stopDialOut({ sessionId: session.sessionId })}>
            Hang up
          </button>
        </div>
      ))}
    </div>
  );
};

See also