Give them XP for resolving and surviving the encounter.###
Yes, D&D is primarily a combat game. However, that doesn't always mean that all encounters must be handled via combat. In practice, combat is just one of several approaches. As it says in the Player's Basic Rules, the "Three Pillars of Adventure" encompass more than just fighting:
Adventurers can try to do anything their players can imagine, but it can be helpful to talk about their activities in three broad categories: exploration, social interaction, and combat.
Player agency is important, which means the players should decide how they want to handle new threats. When goblins introduce a new threat, any of the following methods are possible:
Sneak past the goblins, thereby not being attacked
Sneak up to the goblins and then defeating them in a surprise attack
Charge the goblins head-on and defeating them in brutal combat
Use social skills to persuade, intimidate, or trick the goblins so that they don't attack
Create a distraction to make the goblins go in a different direction
Whenever NPCs interact with the player characters in a potentially challenging way, the players should earn an amount of XP if they meet the challenge goals (which often means surviving the encounter). The Dungeon Master's Guide explains how to calculate the XP reward:
Each monster has an XP value based on its challenge rating. When adventurers defeat one or more monsters - typically by killing, routing, or capturing them - they divide the total XP value of the monsters evenly among themselves.
Even if the challenge is initially presented as a combat, as long as the players survive, they should get the XP for completing the challenge.