***

title: onCall
slug: /reference/typescript/relay/client/on-call
description: Register the inbound call handler.
max-toc-depth: 3
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[call]: /docs/server-sdks/reference/typescript/relay/call

Register the inbound call handler. The provided function is called once for each
`calling.call.receive` event on the subscribed contexts. The function receives a
[`Call`][call] object with all call properties
and control methods.

Only one call handler can be active at a time. Calling `onCall()` again replaces
the previous handler.

## **Parameters**

<ParamField path="handler" type="CallHandler" required={true} toc={true}>
  An async function that receives a [`Call`][call] object. Signature:
  `(call: Call) => void | Promise<void>`.
</ParamField>

## **Returns**

`void`

## **Example**

```typescript {9}
import { RelayClient } from '@signalwire/sdk';

const client = new RelayClient({
  project: process.env.SIGNALWIRE_PROJECT_ID!,
  token: process.env.SIGNALWIRE_TOKEN!,
  contexts: ['default']
});

client.onCall(async (call) => {
  console.log(`Received call: ${call.callId}`);
  await call.answer();
  const action = await call.play([{ type: 'tts', text: 'Hello!' }]);
  await action.wait();
  await call.hangup();
});

await client.run();
```