# How could we could implement server authoritative matchmaking with bots?

**URL:** <https://forum.heroiclabs.com/t/how-could-we-could-implement-server-authoritative-matchmaking-with-bots/1723>\
**Category:** Game Design\
**Tags:** server-framework, matches\
**Created:** [June 21, 2021, 2:03pm UTC](https://forum.heroiclabs.com/t/how-could-we-could-implement-server-authoritative-matchmaking-with-bots/1723 "2021-06-21T14:03:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthiasbruns](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/matthiasbruns/32/385_2.png) [@matthiasbruns](https://forum.heroiclabs.com/u/matthiasbruns)\
**Post date:** [June 21, 2021, 2:03pm UTC](https://forum.heroiclabs.com/t/how-could-we-could-implement-server-authoritative-matchmaking-with-bots/1723/1 "2021-06-21T14:03:39Z")

</div>

Hi dear Nakama team.  
For our game(s) we are looking for a way to enable players to play an authoritative game even when there are no other players in a matchmaker (with a bot).

How would I implement this as a fallback during matchmaking?

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [June 26, 2021, 10:33am UTC](https://forum.heroiclabs.com/t/how-could-we-could-implement-server-authoritative-matchmaking-with-bots/1723/2 "2021-06-26T10:33:29Z")

</div>

Hey @matthiasbruns 👋

> For our game(s) we are looking for a way to enable players to play an authoritative game even when there are no other players in a matchmaker (with a bot).

The authoritative game you want to build; does it use the authoritative multiplayer engine in Nakama for your game logic? If so I would suggest you create the bot logic as part of the match loop.

> How would I implement this as a fallback during matchmaking?

It depends on how you matchmake at the moment. Is it with match listings to find a match to join or the matchmaker to find a set of opponents to play against?

---

<div class="post-metadata">

**Author:** ![matthiasbruns](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/matthiasbruns/32/385_2.png) [@matthiasbruns](https://forum.heroiclabs.com/u/matthiasbruns)\
**Post date:** [June 28, 2021, 8:10am UTC](https://forum.heroiclabs.com/t/how-could-we-could-implement-server-authoritative-matchmaking-with-bots/1723/3 "2021-06-28T08:10:18Z")

</div>

> [@novabyte](#):
>
> The authoritative game you want to build; does it use the authoritative multiplayer engine in Nakama for your game logic? If so I would suggest you create the bot logic as part of the match loop.

Yes, that was the plan 🙂

> [@novabyte](#):
>
> It depends on how you matchmake at the moment. Is it with match listings to find a match to join or the matchmaker to find a set of opponents to play against?

Currently we only implemented socket matchmaking as explained here [https://heroiclabs.com/docs/gameplay-matchmaker/](https://heroiclabs.com/docs/gameplay-matchmaker/)

---

<div class="post-metadata">

**Author:** ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)\
**Post date:** [July 12, 2021, 10:19pm UTC](https://forum.heroiclabs.com/t/how-could-we-could-implement-server-authoritative-matchmaking-with-bots/1723/4 "2021-07-12T22:19:49Z")

</div>

@matthiasbruns Sorry for the late reply. I think for your use case you can just wait until matchmaking fails (because you’ve created a timeout within which it must complete) and then use an RPC function to create a match handler which has bots enabled. This way the player joins the match handler like they would as a regular player against other opponents it’s just the opponents are AI controlled and send messages back to the player.

For an example of using an RPC function to create a match handler and pass arguments into it as part of its `MatchInit` phase. Have a look at this code example:

[nakama-project-template/match\_rpc.ts at master · heroiclabs/nakama-project-template · GitHub](https://github.com/heroiclabs/nakama-project-template/blob/master/match_rpc.ts)

Hope this helps.
