> ## Documentation Index
> Fetch the complete documentation index at: https://docs.daily.co/llms.txt
> Use this file to discover all available pages before exploring further.

# useDialin

> useDialin tracks the readiness of a room to receive PSTN/SIP calls and the state of incoming dial-in sessions.

`useDialin(params?): Object`

Tracks the [dial-in](/docs/daily-js/features/dialin-dialout) readiness of the current room and the
state of incoming caller sessions, and wraps the `daily-js` `startDialIn()` method. Accepts optional
callbacks for the [dial-in events](/reference/daily-js/events/telephony-events).

Readiness is set when a [`dialin-ready`](/reference/daily-js/events/telephony-events#dialin-ready)
event is received. Incoming callers are tracked per session, keyed by `sessionId`. State is reset when
the local participant leaves the meeting or the call instance is destroyed.

<Note>
  Dial-in requires a paid Daily account with a credit card on file. See the
  [Dial-in and dial-out guide](/docs/guides/features/dial-in-dial-out) for setup and requirements.
</Note>

## Parameters

<ParamField body="onDialinReady" type="Function">
  Callback for the [`dialin-ready`](/reference/daily-js/events/telephony-events#dialin-ready) event.
</ParamField>

<ParamField body="onDialinConnected" type="Function">
  Callback for the [`dialin-connected`](/reference/daily-js/events/telephony-events#dialin-connected) event.
</ParamField>

<ParamField body="onDialinStopped" type="Function">
  Callback for the [`dialin-stopped`](/reference/daily-js/events/telephony-events#dialin-stopped) event.
</ParamField>

<ParamField body="onDialinError" type="Function">
  Callback for the [`dialin-error`](/reference/daily-js/events/telephony-events#dialin-error) event.
</ParamField>

<ParamField body="onDialinWarning" type="Function">
  Callback for the [`dialin-warning`](/reference/daily-js/events/telephony-events#dialin-warning) event.
</ParamField>

## Return value

Returns an object with the following properties:

<ResponseField name="isReady" type="boolean">
  `true` once a `dialin-ready` event has been received, meaning the room's SIP endpoint is ready to
  receive incoming calls.
</ResponseField>

<ResponseField name="sipEndpoint" type="string">
  The room's SIP endpoint. Populated after `dialin-ready`.
</ResponseField>

<ResponseField name="provider" type="string">
  The SIP/PSTN service provider. Populated after `dialin-ready`.
</ResponseField>

<ResponseField name="sessions" type="Object">
  A map of incoming dial-in caller sessions, keyed by `sessionId`.

  <Expandable title="session properties">
    <ResponseField name="sessions[sessionId].sessionId" type="string">
      The session ID of the incoming caller.
    </ResponseField>

    <ResponseField name="sessions[sessionId].status" type="string">
      The latest status for the session: `'connected'`, `'stopped'`, `'error'` or `'warning'`.
    </ResponseField>

    <ResponseField name="sessions[sessionId].provider" type="string">
      The SIP/PSTN service provider for the session, when reported.
    </ResponseField>

    <ResponseField name="sessions[sessionId].sipCallId" type="string">
      The SIP call ID for the session, when reported.
    </ResponseField>

    <ResponseField name="sessions[sessionId].errorMsg" type="string">
      The error or warning message, set when `status` is `'error'` or `'warning'`.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="startDialIn" type="Function">
  Wraps `daily-js`'s `startDialIn()` method.
</ResponseField>

## Example

```jsx theme={null}
import { useDialin } from '@daily-co/daily-react';

export const DialinStatus = () => {
  const { isReady, sipEndpoint, sessions } = useDialin({
    onDialinError: (ev) => console.error('Dial-in error', ev.errorMsg),
  });

  return (
    <div>
      <p>
        Dial-in {isReady ? 'ready' : 'not ready'}
        {sipEndpoint ? ` at ${sipEndpoint}` : ''}
      </p>
      <p>{Object.keys(sessions).length} caller(s) connected</p>
    </div>
  );
};
```

## See also

<CardGroup>
  <Card title="Hooks" icon="code" iconType="solid">
    * [useDialOut()](/reference/daily-react/use-dialout)
  </Card>

  <Card title="Events" icon="bolt" iconType="solid">
    * [dialin-ready](/reference/daily-js/events/telephony-events#dialin-ready)
    * [dialin-connected](/reference/daily-js/events/telephony-events#dialin-connected)
    * [dialin-stopped](/reference/daily-js/events/telephony-events#dialin-stopped)
    * [dialin-error](/reference/daily-js/events/telephony-events#dialin-error)
    * [dialin-warning](/reference/daily-js/events/telephony-events#dialin-warning)
  </Card>

  <Card title="Guides" icon="book-open" iconType="solid">
    * [Dial-in and dial-out](/docs/guides/features/dial-in-dial-out)
  </Card>
</CardGroup>
