Problem connecting Alexa with RingCentral Messaging

  • 1
  • Problem
  • Updated 10 months ago
I have created an Alexa skill based on a post by Phong Vu for Turning Alexa into Your Personal Messaging Assistant.  When I invoke my skill Alexa says "Hi <MyName>Unfortunately, your account does not support SMS message."

I have confirmed that my sandbox account has the SMS permission granted.

So what do I need to do to resolve this issue?
Photo of Hack

Hack

  • 160 Points 100 badge 2x thumb

Posted 10 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 3,072 Points 3k badge 2x thumb
Hi Hack,

The error message is just for all failures. Can you log the error/response and see what is the actual reason why it failed.

+ Phong
Photo of Hack

Hack

  • 160 Points 100 badge 2x thumb
Hi Phong,

It seems to fail where the comment shows "should check if there is no direct number" in the index.js file of my Lambda function.  The CloudWatch log doesn't show any errors.

Hack
Photo of Phong Vu

Phong Vu, Devangelist

  • 2,816 Points 2k badge 2x thumb
Can you add this block into your code after the for (var record of .. loop

if (!thisHandler.attributes['ownPhoneNumber']) {
    for (var record of jsonObj.records){
        if (record.usageType == "MainCompanyNumber"){
            thisHandler.attributes['ownPhoneNumber'] = record.phoneNumber.replace("+", "") + "*" + thisHandler.attributes['extensionNumber']
            break;
        }
    }
}
console.log("own number: " + thisHandler.attributes['ownPhoneNumber'])

If it still does not work, check the log to see if it can find your own number.

+ Phong
Photo of Hack

Hack

  • 160 Points 100 badge 2x thumb
Phong,

Thanks... I think the problem may have been that I was publishing a package-lock.json file in the zip file I was uploading to my Lambda function.

Anyway, for some reason the skill appears to be partly working now, and my number does appear in the log.  The reason I say partly is because when I try to send a reply to a text message that gets read back to me through the Alex Service Simulator, it doesn't successfully allow me to reply to the message.  After I formulate my reply message body, Alexa asks me if I want to send the message.  When I say yes, Alexa responds with, "Sorry I cannot send the message, please try again".

Also, is there functionality with the RingCentral API to allow you to retrieve voice mail messages?
Photo of Hack

Hack

  • 160 Points 100 badge 2x thumb
On the reply, it doesn't appear to be grabbing my from.phoneNumber. Here's what the log was showing:

{ Error: Parameter [from.phoneNumber] value is invalid
at EventEmitter.<anonymous> (/var/task/node_modules/ringcentral/src/http/Client.js:62:38)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Photo of Phong Vu

Phong Vu, Devangelist

  • 2,816 Points 2k badge 2x thumb
Can you print out this.attributes['ownPhoneNumber'] and check if that is your account/extension phone number?

For voicemail, please complete and try this code
platform.get('/account/~/extension/~/message-store', {
    messageType: "VoiceMail",
    readStatus: "Unread",
    direction: "Inbound",
    dateFrom: "2017-07-07T23:59:59.999Z" // any day you want
    })
    .then(function (response) {
        //console.log(response)
        var records = response.json().records;
        var count = records.length;
        var voiceMailsArr = []
        if (count > 0) { //if there is a voicemail
            for (var i=count-1; i>=0; i--) {
                var record = records[i]
                ...

Remember that you have to implement Alexa audio player directive to playback voicemails. You cannot use SSML because of Alexa required audio format is different from RC voicemail audio format.

+ Phong
(Edited)
Photo of Hack

Hack

  • 160 Points 100 badge 2x thumb
Yes, in the CloudWatch logs it is showing my phone#*extension after own number: which is being output to the console.

Also, I only have the one Super Admin user setup in the sandboxed account, so I'm not sure if that matters. Since it was the From number that appeared to be causing the issue, I looked at my RingCentral Settings for that Super Admin user.  I notice that it doesn't have a number listed for the user (it shows N/A), but it does have a number for the main account.  Could this be causing the issue?
Photo of Phong Vu

Phong Vu, Devangelist

  • 2,816 Points 2k badge 2x thumb
I see. That is why it does not work. The *extension# will only work for ring-out to make a call. You can try to remove the "*" and don't add the extension. OR add a direct number to your main user.
thisHandler.attributes['ownPhoneNumber'] = record.phoneNumber.replace("+", "")
Hope this helps.
Phong
Photo of Hack

Hack

  • 160 Points 100 badge 2x thumb
It won't let me add a direct number, I'm guessing that's because it's a developer or sandbox account.  But removing the "*" and extension worked, and so now it at least let's me reply to a message and send it. 

Now, I will add the ability to retrieve voicemails via the code you sent above.

Thanks for your help!
Photo of Phong Vu

Phong Vu, Devangelist

  • 2,816 Points 2k badge 2x thumb
How come you cannot add a direct number. Login your admin console. Select the main user and under the Phones & Numbers tab, click Add Direct Number. I know that most of the States/Provinces have run out of test number. But Quebec still has lots of free numbers.

+ Phong
Photo of Hack

Hack

  • 160 Points 100 badge 2x thumb
I'm in the US.  Can I pick a Canadian number for just testing, and if so, does it cost money even though I'm only testing?
Photo of Phong Vu

Phong Vu, Devangelist

  • 2,816 Points 2k badge 2x thumb
No cost for sandbox account. You can try several other U.S states to find available numbers.