question

Bob Colladay avatar image
Bob Colladay asked Bob Colladay commented

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);
                        }
                    }
                }
            }
        }
    }
}


voicemail
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Bob Colladay avatar image Bob Colladay commented ·

This is the call queue I will need to access.

https://service.ringcentral.com/application/company/departments/63448800004/messages

0 Likes 0 ·

1 Answer

Phong Vu avatar image
Phong Vu answered Bob Colladay commented

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();
    ...
}


3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Bob Colladay avatar image Bob Colladay commented ·

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

0 Likes 0 ·
vm9000.jpg (62.6 KiB)
Phong Vu avatar image Phong Vu ♦♦ Bob Colladay commented ·

Extension id is not the extension number. 9000 is your queue extension number.

You can read the call queue info using the list extensions API (set the type query param to ["Department"]) and grab the id from the result.

0 Likes 0 ·
Bob Colladay avatar image Bob Colladay Phong Vu ♦♦ commented ·

ok, thanks again

0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys