# Chat

## Introduction

This guide will help projects wanting to use a chat system that integrates with a 3rd party chat provider (as opposed to the default unreal chat system provided). There are a number of benefits for rolling an integrated chat solution in your Unreal project:

1. **Scalability**: 3rd party solutions can be better placed to handle the large volume of concurrent users and messages efficiently. This is particularly beneficial for projects developed on our platform, which expect thousands of users in one experience.
2. **Improved Performance**: 3rd party chat solution providers are often better optimised for real-time, low-latency communication across global networks.
3. **Advanced Features**: many third party solutions contain advanced features that would otherwise be difficult to implement/unavailable. These include features like:
   1. Presence Detection
   2. Built-in Moderation Capabilities
   3. Message Persistence and History
   4. Customizable Channels

For the purposes of this guide, we will be using [Pubnub](https://www.pubnub.com/) as our example. Pubnub's feature-rich [free tier](https://www.pubnub.com/pricing/) offers a variety of chat options that you may find useful for your project. They include:

1. Up to 1 million total messages per month
2. Data persistence of up to 1GB
3. Custom function modules for Moderation
4. Easy integration with Unreal via Pubnub APIs

Follow the steps below to get started with setting up your first Pubnub application!

## Creating your Pubnub Application

Firstly, create an account with [Pubnub](https://www.pubnub.com/). Then create a new app:

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-7874dce8bf738bfbcab428041a132618f47d803d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

Once created, set up a new Keyset within the application, with an appropriate name (see above).

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-d5bc634fc844fb6b993be87d1c4c65f3c5b3ea83%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

You can configure your keyset, however you like; to get started, we recommend configuring as follows:

1. **Presence**: `ON`
   1. Defaults are usually fine
      1. Announce Max: `20`
      2. Interval: `30`
      3. Stream Filtering: `ON`
2. **App Context**: `ON`
   1. Region: `EU Central` (or US)
   2. User Metadata Events: `ON`
   3. Channel Metadata Events: `ON`
   4. Membership Events: `ON`
3. **Message Persistence**: `ON`
   1. Retention: 7`days`
   2. Enable Delete-From-History: `ON`
4. **Stream Controller**: `ON`
   1. Enable Wildcard Subscribe: `ON` (but could be `OFF` ?)
5. **File Sharing**: `OFF`
6. **Mobile Push Notifications**: `OFF`
7. **Apple Push Notifications**: `OFF`
8. **Firebase Cloud Messaging**: `OFF`

If you want to strictly enable authed users only chatting for your keyset:

9. **EnableAccess Manager**: `ON`
   1. Revoke v3 Token: `ON`

## Next Steps

Once completed, you're ready to integrate with your newly created app and keyset!

:video\_game: To learn how to integrate Pubnub with your Unreal project, [view our guide here](https://docs.msquared.io/integrations/3rd-party-chat/integrating-pubnub-unreal-engine)!

:anger: To learn how to set up custom functions like Modetation for your Pubnub keyset, [view our guide here](https://docs.msquared.io/integrations/3rd-party-chat/adding-moderation-to-pubnub)!
