I’ve tested several scenarios, and unfortunately, changing the status to “Away” doesn’t revert the user’s status to “Available” after the set time expires.
Interestingly, when I switch the status to “Do Not Disturb,” the presence status does return to “Available” after the designated time lapses.
Hi @amushtaq
Thanks for reaching out to us!
Have you been able to troubleshoot this on your end?
Also could you please share with me the workflow you are following so I can try and replicate this on my end?
Thank you for your response. To provide some context, we operate a C# service that runs daily and automatically marks users as “Away” if they have a holiday booked in our HR system. However, during testing, we discovered that once a user’s status is set to “away,” they are not automatically switched back to “online” when the designated time period has elapsed.
I also tested the same code and marked the status to ''Do_Not_Disturb", in that case the user was set back to online when the timer period elapsed.
code :
public async Task Invoke()
{
AppLog.Instance.Write("UpdatePresenceStatus Job Started");
_settings ??= await _sqlDal.GetZoomSetting();
List<Holiday> holidays = await _sqlDal.GetHolidayRelations();
DateTime targetDate = new DateTime(2023, 9, 5);
try
{
if (holidays.Count()>0)
{
foreach (var item in holidays)
{
SetMemberPresenceStatus(item, "Away", 1000);
}
}
}
catch (Exception exception)
{
AppLog.Instance.WriteError(exception.Message, exception.InnerException);
}
}
public async Task<bool> SetMemberPresenceStatus(Holiday member, string presenceStatus,int duration)
{
_settings ??= await _sqlDal.GetZoomSetting();
await RefreshAccessToken();
try
{
var handler = new HttpClientHandler();
using (var client = new HttpClient(new RetryHandler(handler)))
{
client.BaseAddress = new Uri("https://api.zoom.us/");
client.DefaultRequestHeaders.Clear();
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", _settings.AccessToken);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var endpoint = $"v2/users/{member.Email}/presence_status";
// Create the JSON body
var jsonBody = new
{
duration = duration,
status = presenceStatus
};
var jsonContent = new StringContent(JsonConvert.SerializeObject(jsonBody), Encoding.UTF8, "application/json");
var response = await client.PutAsync(endpoint, jsonContent);
if (!response.IsSuccessStatusCode)
{
var errorMessage = await response.Content.ReadAsStringAsync();
AppLog.Instance.Warn($"Code: {response.StatusCode}, Reason: {response.ReasonPhrase}");
AppLog.Instance.WriteError($"Error Response: {errorMessage}");
return false;
}
return true;
}
}
catch (Exception exception)
{
AppLog.Instance.WriteError(exception.Message, exception.InnerException);
return false;
}
}
I am happy to get on a screen share session and show you the use case using our IDE.
Hi @amushtaq
Thanks for your patience here, I just did some testing on my end and it looks like the duration field is only valid when using the status “Do_Not_Disturb” that is why when you pass the status Away with a duration field, it does not change anything on your end