# Manage calls and messages

This section describes how to configure call center-specific features and how to manage messages within Conversations. All standard Conversations setup steps apply here as well.

## Calls

To learn how to make and receive calls, refer to the [WebRTC calls](https://www.infobip.com/docs/voice-and-video/webrtc) documentation.

Below is a high-level overview of the required setup and call center integration steps.

### Prerequisites [#prerequisites-calls]

Before working with calls, complete the following:

1. **Create an application** using the *Use Conversations* configuration option.
2. [Register agents](https://www.infobip.com/docs/api/channels/webrtc-calls/webrtc) using their [Agent ID](https://www.infobip.com/docs/api/customer-engagement/conversations/conversation-agents/create-agent).
3. [Add the Infobip RTC JS SDK](https://github.com/infobip/infobip-rtc-js/wiki/Getting-SDK) to your application.

### Make calls [#make-calls-calls]

To make an outbound call:

1. <apidocslink href="customer-engagement/conversations/outbound-call-conversation-calls/create-conversation-outbound-call">Create an outbound call conversation</apidocslink>.
2. Generate [`CallOptions`](https://github.com/infobip/infobip-rtc-js/wiki/CallOptions), including the following parameters inside [`customData`](https://github.com/infobip/infobip-rtc-js/wiki/CallOptions#customData):
   - `conversationsID` - obtained from the conversation created in the previous step.
   - `calleeClientType` - `WebRTC` for in-app calls or `PSTN` for calls to phone numbers.
    
    const callOptions = CallOptions.builder()
           .setCustomData({
               isOutbound: true,
               outboundTo: outgoingCallRequest.destination,
               outboundFrom: outgoingCallRequest.sender,
               outboundAgentId: this.context.user.agentId,
               conversationId: outgoingCallRequest.conversationId,
               calleeClientType: calleeClientType,
           }).build();

3. Use the [`callConversations`](https://github.com/infobip/infobip-rtc-js/wiki/InfobipRTC#callConversations) method with the `CallOptions`.
4. Manage the conversation as you would for any other channel.

### Receive calls [#receive-calls-calls]

To receive calls:

1. Configure your [Voice number](https://www.infobip.com/docs/voice-and-video/configure-inbound-calls) to forward calls to **Conversations**, or use the <apidocslink href="channels/voice/interactive-voice-response/create-a-voice-ivr-scenario">Dial to Conversations</apidocslink> script in IVR.
2. You can also initiate a call from your application to Conversations using the `callConversations` method ([Web](https://github.com/infobip/infobip-rtc-js/wiki/InfobipRTC#callConversations), [Android](https://github.com/infobip/infobip-rtc-android/wiki/CallConversationsRequest), [iOS](https://github.com/infobip/infobip-rtc-ios/wiki/CallConversationsRequest)).
3. <apidocslink href="customer-engagement/conversations/conversation-agents/update-agent-heartbeat">Set agent heartbeat</apidocslink>.
4. Register the **incoming call event handler** on the [InfobipRTC](https://github.com/infobip/infobip-rtc-js/wiki/InfobipRTC) client and implement answering and rejecting logic.

### Wrap-up time [#wrap-up-time-calls]

After a call ends, agents may need time to write notes or summaries before closing the conversation.

During wrap-up:

- The agent is considered **busy**.
- The default wrap-up duration is **30 seconds**, adjustable at:
  - <apidocslink href="customer-engagement/conversations/get-conversations-account-wrap-up-config">System level</apidocslink>
  - <apidocslink href="customer-engagement/conversations/wrap-up-configuration-calls/update-conversations-agent-wrap-up-config">Agent level</apidocslink>
- **Agent-level settings override system settings**.
- Supervisors can <apidocslink href="customer-engagement/conversations/wrap-up-configuration-calls/update-conversations-agent-wrap-up-config">view, modify, or delete agent-level configuration</apidocslink>.
- Agents can <apidocslink href="customer-engagement/conversations/add-conversations-agent-wrap-up-time">extend</apidocslink> or <apidocslink href="customer-engagement/conversations/wrap-up-time-calls/clear-conversations-agent-wrap-up-time">clear</apidocslink> wrap-up time based on their needs if the options are enabled.

### Waiting strategy [#waiting-strategy-calls]

A waiting strategy shapes the caller experience while they wait to connect with an agent.

You can configure:

- **Strategy name**
- **Applicable numbers or applications**
- **Maximum waiting time**

Optional components:

- **Greeting message** - played at the beginning of the call
- **Hold music** - audio played while waiting
- **Announcement message** - periodic updates for callers
- **Maximum wait time message** - played before the call

[Learn more about the waiting strategy for calls](https://www.infobip.com/docs/conversations/calls-in-conversations/set-up-calls#call-waiting-strategy).

With the available API methods, you can:

- <apidocslink href="customer-engagement/conversations/waiting-strategies-calls/get-conversations-waiting-strategies">Retrieve all waiting strategies</apidocslink>
- <apidocslink href="customer-engagement/conversations/waiting-strategies-calls/create-conversations-waiting-strategy">Create a waiting strategy</apidocslink>
- <apidocslink href="customer-engagement/conversations/waiting-strategies-calls/get-conversations-waiting-strategy">Retrieve a waiting strategy by its ID</apidocslink>
- <apidocslink href="customer-engagement/conversations/waiting-strategies-calls/update-conversations-waiting-strategy">Update a waiting strategy</apidocslink>
- <apidocslink href="customer-engagement/conversations/waiting-strategies-calls/delete-conversations-waiting-strategy">Delete a waiting strategy by its ID</apidocslink>

### Transfer calls [#transfer-calls-calls]

Currently, there are three methods available for transferring calls:

- <apidocslink href="customer-engagement/conversations/transfers-calls/transfer-call-to-agent">Transfer call to another agent</apidocslink>
- <apidocslink href="customer-engagement/conversations/transfers-calls/transfer-call-to-queue">Transfer call to another queue</apidocslink>
- <apidocslink href="customer-engagement/conversations/transfers-calls/transfer-call-to-external-number">Transfer call to external number</apidocslink>

Additionally, you can <apidocslink href="customer-engagement/conversations/transfers-calls/get-transfer-queues">retrieve a list of all queues</apidocslink> and return them along with their current activity status.

### Recording [#recording-calls]

You can <apidocslink href="customer-engagement/conversations/recording-configuration-calls/create-conversations-account-recording-config">create account recording configuration</apidocslink> to record agent-customer conversations to comply with regulatory requirements, ensure quality, or support other business needs.

#### System-level recording settings

You can choose to record:

- **Inbound calls** (answered by agents)
- **Outbound calls** (initiated by agents)
- **Both inbound and outbound**

#### Recording video calls

Calls in Conversations can include video. You can decide how these calls should be recorded:

- **Media type**: audio only, video only, or both.
- **Default behavior**:

Video calls are recorded and stored in Infobip cloud storage as **high-quality streamable files** that **cannot be downloaded**.

To generate files you can download, copy, or move to your own storage, enable **Video Download Preparation**.

Note
Preparing video files for download may take time depending on file duration, service load, and internet connection.

#### Configuration management

- All recording settings can be <apidocslink href="customer-engagement/conversations/recording-configuration-calls/get-conversations-account-recording-config">viewed</apidocslink> or <apidocslink href="customer-engagement/conversations/recording-configuration-calls/update-conversations-account-recording-config">changed</apidocslink> at any time.
- You can override system-level settings with **agent-level configuration**.
- Agent-level setup can be <apidocslink href="customer-engagement/conversations/recording-configuration-calls/create-conversations-agent-recording-config">created</apidocslink>, <apidocslink href="customer-engagement/conversations/recording-configuration-calls/get-conversations-agent-recording-config">viewed</apidocslink>, and <apidocslink href="customer-engagement/conversations/recording-configuration-calls/update-conversations-agent-recording-config">updated</apidocslink> when needed.

#### Recording file management

You can <apidocslink href="channels/voice/calls/files-and-recordings/get-call-recordings">get</apidocslink>, <apidocslink href="channels/voice/calls/files-and-recordings/download-recording-file">download</apidocslink>, and <apidocslink href="channels/voice/calls/files-and-recordings/delete-recording-file">delete</apidocslink> recording files.

## Messages

You can use [Messages API](https://www.infobip.com/docs/messages-api) for engagement campaigns where a new conversation is created when sending the initial [mobile-terminated (MT) message](https://www.infobip.com/glossary/mt-mobile-terminated).

### Create messages [#create-messages-messages]

Inbound messages are automatically threaded if channels and senders are configured for conversation threading.

To add outbound messages to a conversation, use the <apidocslink href="customer-engagement/conversations/conversation-messages/create-message">Create message</apidocslink> method to send a message through any supported channel.

### Get messages [#get-messages-messages]

Use the <apidocslink href="customer-engagement/conversations/conversation-messages/get-messages">Get messages</apidocslink> method to retrieve all messages exchanged within a conversation.

### `x-agent-id` attribute [#x-agent-id-attribute-messages]

The `x-agent-id` HTTP header attribute identifies the agent sending the message.

It is used when integrations authenticate with an API key and need to associate outgoing messages with a specific agent.

- The value is the **agentId**, which is the primary key of the agent entity.
- You can find `agentId` in responses from the Agents API.
- Adding `x-agent-id` to every request is **not** mandatory since its use depends on whether your account uses agents.

#### Behavior matrix

| Conversation assignment status | No `x-agent-id` provided | `x-agent-id = AGENT` | `x-agent-id = SUPERVISOR` |
|-------------------------------|---------------------------|------------------------|-----------------------------|
| **Unassigned**                | OK (no-agents-used scenario) | Error | Error |
| **Assigned to Agent**         | Error | OK | OK |
| **Assigned to Supervisor**    | Error | Error | OK |

#### Usage rules

If you **do not use agents**:

- Keep conversations **unassigned**.
- Omit the `x-agent-id` parameter entirely from the `Create Message` request header.

If you **use agents**:

- Your account must have **at least one agent** (license not required) created via the <apidocslink href="customer-engagement/conversations/conversation-agents/create-agent">Create agent</apidocslink> API.
- The `x-agent-id` header **must** contain the correct `agentId`, depending on who is sending the message.

#### Role behavior

- **Agent** role can reply only to conversations assigned to them.
- **Supervisor** role can reply to **any** conversation.
- The `x-agent-id` header must always reflect the correct `agentId` based on who is performing the action.
