# 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. Create an outbound call conversation.
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 Dial to Conversations 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. Set agent heartbeat.
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:
  - System level
  - Agent level
- **Agent-level settings override system settings**.
- Supervisors can view, modify, or delete agent-level configuration.
- Agents can extend or clear 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:

- Retrieve all waiting strategies
- Create a waiting strategy
- Retrieve a waiting strategy by its ID
- Update a waiting strategy
- Delete a waiting strategy by its ID

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

Currently, there are three methods available for transferring calls:

- Transfer call to another agent
- Transfer call to another queue
- Transfer call to external number

Additionally, you can retrieve a list of all queues and return them along with their current activity status.

### Recording [#recording-calls]

You can create account recording configuration 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 viewed or changed at any time.
- You can override system-level settings with **agent-level configuration**.
- Agent-level setup can be created, viewed, and updated when needed.

#### Recording file management

You can get, download, and delete 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 Create message method to send a message through any supported channel.

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

Use the Get messages 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 Create agent 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.