Skip to main content
The First Step
July 18, 2023
Question

How do I get the voicemail transcription from a Group using C#

First I am unable to get even my own personal voicemail transcriptions using this method. It find the transcription record but I can't see any parameters with the transcription string.

Second how will I change this to access a Group's voicemail transcription?

Thanks.


using System;
using System.Threading.Tasks;
using RingCentral;

namespace Account
{
    class Account
    {
        static String SERVER_URL = "https://platform.ringcentral.com";
        static String CLIENT_ID = "************";
        static String CLIENT_SECRET = "********";
        static String JWT_TOKEN = "************";    

        static RestClient restClient;

        static void Main(string[] args)
        {
            restClient = new RestClient(CLIENT_ID, CLIENT_SECRET, true, "VoiceMailTranscriptionGet");
            restClient.Authorize(JWT_TOKEN).Wait();
            GetMessage().Wait();
        }



        static private async Task GetMessage()
        {
            ListMessagesParameters parameters = new ListMessagesParameters();
            parameters.messageType = new String[] { "VoiceMail" };
            var response = await restClient.Restapi().Account().Extension().MessageStore().List(parameters);
            foreach (GetMessageInfoResponse record in response.records)
            {
                if (record.attachments != null)
                {
                    foreach (var attachment in record.attachments)
                    {
                        var fileName = "./src/test/resources/" + record.attachments[0].id + "_voicemail.txt";
                        if (attachment.type == "AudioTranscription")
                        {
                            var res = restClient.Restapi().Account().Extension().MessageStore(record.id.ToString()).Content(attachment.id.ToString()).Get();
                            //Path path = Paths.get(fileName);
                            //Files.write(path, res);
                        }
                    }
                }
            }
        }
    }
}


3 replies

bcolladayThe First StepAuthor
The First Step
July 18, 2023
PhongVu
Community Manager
Community Manager
July 19, 2023

First of all, you have to make sure also the voicemail transcription is Completed

if (attachment.type == "AudioTranscription" &&
                                         record.vmTranscriptionStatus == "Completed")
{
    ...
    var res = await restClient.Restapi().Account().Extension().MessageStore(record.id.ToString()).Content(attachment.id.ToString()).Get();
    using (BinaryWriter writer = new BinaryWriter(System.IO.File.Open(path + fileName, FileMode.Create)))
    {
        writer.Write(res);
        writer.Flush();
        writer.Close();
    }
}

If you need to access and download a message store content (e.g. voicemail) of another user extension, including a group's voicemail (call queue), you must authenticate your app with a super admin user, and specify the extension id in the path as shown in the example below:

...
var EXTENSION_ID = "12345678890";
var resp = await restClient.Restapi().Account().Extension(EXTENSION_ID).MessageStore().List(parameters);
                
foreach (var record in resp.records)
{
    ...
    var res = await restClient.Restapi().Account().Extension(EXTENSION_ID).MessageStore(record.id.ToString()).Content(attachment.id.ToString()).Get();
    ...
}


bcolladayThe First StepAuthor
The First Step
July 19, 2023

I added the EXTENSION_ID var and valued it to 9000, now I get "Resource for parameter [extensionId] is not found"

this is for a call queue group with an extension of 9000

vm9000.jpg