Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skill Messaging API Not Sending Message to Local Skill #692

Open
chandora opened this issue Jun 17, 2021 · 11 comments
Open

Skill Messaging API Not Sending Message to Local Skill #692

chandora opened this issue Jun 17, 2021 · 11 comments
Assignees
Labels

Comments

@chandora
Copy link

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

The Skill Messaging API does not send a message to a skill when the skill is running in a local environment with Alexa Skills Toolkit (ask-sdk-local-debug) on VS Code.

Expected Behavior

The Skill Messaging API sends a message to a skill running in a local environment.

Current Behavior

A message sent via Skill Messaging API is not routed to a skill running in VS Code with Alexa Skills Toolkit (ask-sdk-local-debug). Instead, the message is routed to the skill running in the Alexa-hosted environment. Other messages like LaunchIntent request are sent to the skill in the local environment as expected.

Possible Solution

Steps to Reproduce (for bugs)

  • Run a skill in a local environment using Alexa Skills Toolkit (ask-sdk-local-debug) on VS Code
  • Send a message to the skill via Skill Messaging API

Context

Your Environment

  • Ask CLI: 2.22.4
  • ask-sdk-core: 2.10.1
  • ask-sdk-model: 1.35.1
  • ask-sdk-local-debug: 1.1.0
  • Windows 10

Node.js and NPM Info

  • Node.js v12.13.1
  • NPM 7.10.0
@Shreyas-vgr
Copy link
Contributor

Hi @chandora, thanks for raising this issue. I will reach out to the concerned team regarding this issue and revert back.

@sattpat
Copy link
Contributor

sattpat commented Jun 24, 2021

Hey @chandora can you tell me your skill Id ?

@chandora
Copy link
Author

chandora commented Jun 26, 2021

@Shreyas-vgr and @sattpat

Thank you for your investigation.
My skill Id is as follows:

amzn1.ask.skill.baad1b9a-fff8-458b-925b-b95d1bf6749b

Please note that the skill has been published, and I experienced the issue with one in the development stage being updated for the next release.

If you need to check a log for the issue, please let me know. I will re-run the test case to reproduce the issue.

Thank you,

@sattpat
Copy link
Contributor

sattpat commented Jun 28, 2021

Hey @chandora , I didnt read the your entire issue the first time. So just to be clear, your local debug connection is working for launch intents only? What about other intent requests?

How are you invoking the Skill Messaging API? How did you verify that the the skill requests are not making it to your debug connection? I am online on Gitter. So feel free to ping me there so that we can coordinate a simulation if it comes down to that.

@chandora
Copy link
Author

@sattpat

Thank you for your reply.
As we are in different timezones (I am in Japan), it seems to be difficult to contact you via Gitter.

My local debug connection is not working only for Launch intent but also for other requests. They include request types for LaunchRequest, IntentRequest, Alexa.Presentation.APL.UserEvent and Connections.Response (AskFor). I confirmed it by checking log messages from my code and SDK in the debug console of VS Code.

I could not see any log message in the debug console, neither from my code nor SDK, when I invoked the Skill Messaging API. After some investigation, I found log messages from my code for Messaging. MessageReceived request in the ClouldWatch log for the same skill running in the Alexa-Hosted environment. They were logged while other requests were received in the local debugging environment.

I invoked Skill Messaging API using SDK. Without the local debug connection, all requests including Skill Messaging API are routed to the skill in the Alexa-Hosted environment. So I assume my procedure of using the API is okay.

Just in case, the following is the code using Skill Messaging API. (I am developing a test driver for skills, and the Skill Messaging API is invoked to load test data to S3 store.)

import * as Alexa from 'ask-sdk-core';
import * as Model from 'ask-sdk-model';

export async function setupTestDataRemotely(medicationData: MDEF.MedicationData | undefined) {
assert.isDefined(medicationData, 'Medication Data Undefined');
assert.isNotNull(medicationData, 'Medication Data Null');

const clientId = config.messaging_client_id;
const clientSecret = config.messaging_client_secret;
const userId = config.user_id;

const apiConfiguration: Model.services.ApiConfiguration = {
    apiClient: new Alexa.DefaultApiClient(),
    apiEndpoint: 'https://api.fe.amazonalexa.com',
    authorizationValue: ""
};

const authentificationConfiguration: Model.services.AuthenticationConfiguration = {
    clientId,
    clientSecret
};

const serviceClient = new Model.services.skillMessaging.SkillMessagingServiceClient(
    apiConfiguration,
    authentificationConfiguration);

const message: Model.services.skillMessaging.SendSkillMessagingRequest = {
    data: medicationData,
    expiresAfterSeconds: 60
};

try {
    await serviceClient.sendSkillMessage(userId, message);
}
catch (error) {
    console.log(JSON.stringify(error, null, 2));
    throw error;
}

}

@Shreyas-vgr
Copy link
Contributor

Hi @chandora, thanks for the detailed steps to reproduce the issue, can you also share the local debug configuration snippet you are executing from VSCode ?

@sattpat
Copy link
Contributor

sattpat commented Jun 29, 2021

I looked at the logs and I will list my observations here.

  1. You local debug connection is pointing to North America(NA). I see some successful skill requests coming through and assuming that you are using vscode/' dev console to make those requests, that means that your developer account is in NA as well? As pointed out by @Shreyas-vgr above can you please share your launch config?
  2. For the skill requests you are trying to make using the Skill Messaging API, the endpoint specified is - https://api.fe.amazonalexa.com. Since the debug connection is setup to NA, hence you dont see the logs for the requests made. Assuming that your account is pointing to NA, changing https://api.fe.amazonalexa.com to https://api.amazonalexa.com should unblock you.

check point 3 under https://developer.amazon.com/en-US/docs/alexa/ask-toolkit/vs-code-testing-simulator.html#prepare-test

@chandora
Copy link
Author

@sattpat and @Shreyas-vgr ,

I attach the debug configuration below.
As you can see, it is pointing to FE region.

As my account was made in amazon.co.jp's Web site, I guess my account is in FE (but not sure).
The request messages coming to my skill contain "apiEndPoint": "https://api.fe.amazonalexa.com".

I am invoking the skill from the developer console, VS Code, and my test driver running on Node using SMAPI and Skill Messaging API. The normal skill requests from them like LaunchRequest, IntentRequest ... are received by the local skill. Only the message from the Skill Messaging API is not received.

In addition, the message sent via Skill Messaging API (pointing to FE) is received by the host skill.

So I infer the connection to FE is correct and the issue seems to be specific to the connection for the Skill Messaging API.

I see some successful skill requests coming through

At the beginning of local-debug experience (a couple of months ago), it was pointed to NA and did not work. If you mean that you saw messages coming to NA, is it possible you saw messages sent in that old configuration?

    {
        "name": "Debug Alexa Skill (Node.js)",
        "type": "node",
        "request": "launch",
        "program": "${command:ask.debugAdapterPath}",
        "outputCapture": "std",
        "args": [
            "--accessToken",
            "${command:ask.accessToken}",
            "--skillId",
            "${command:ask.skillIdFromWorkspace}",
            "--handlerName",
            "handler",
            "--skillEntryFile",
            "${workspaceFolder}/lambda/index.js",
            "--region",
            "FE"
        ],
        "cwd": "${workspaceFolder}/lambda",
        "envFile": "${workspaceFolder}/lambda/test/.env"
    }

@jazmit
Copy link

jazmit commented Nov 10, 2021

Hello, I'm experiencing a similar issue, I can't get any of my requests routed to my local machine.

I followed the instructions here: https://developer.amazon.com/en-US/docs/alexa/smapi/ask-cli-intro.html#test-locally
ask run works as expected:

*****Once the session is successfully started, you can use `ask dialog` to make simulation requests to your local skill code*****

Region chosen: NA
*****Starting Skill Debug Session*****

*****Session will last for 1 hour*****

But running ask dialog, or even ask dialog -g development -l en-US connects to the deployed version of the skill and is unaffected by local code changes.

My skill ID is amzn1.ask.skill.c6ecc7f8-ee7a-4518-9798-4c1229ed7d5b

I'm based in the UK, which is where I originally opened my amazon dev account, but I've set my skill up with the en-US locality and use the NA region.

@rahulawl
Copy link
Contributor

Is this issue/feature-request still relevant?
We are working on prioritization of relevant issues and cleanup of rest. If we don’t hear back in 2 weeks, we will assume that the issue is not relevant and we will close it.

@chandora
Copy link
Author

Hi, I have given up using Skill Messaging API, so it is no longer relevant to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants