GithubHelp home page GithubHelp logo

alexa / alexa-apis-for-nodejs Goto Github PK

View Code? Open in Web Editor NEW
61.0 61.0 33.0 1.1 MB

The Alexa APIs for NodeJS consists of JS and Typescript definitions that represent the request and response JSON of Alexa services. These models act as core dependency for the Alexa Skills Kit NodeJS SDK (https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs).

License: Apache License 2.0

JavaScript 0.23% TypeScript 99.77%

alexa-apis-for-nodejs's People

Contributors

ask-sdk avatar jpeddicord avatar kakhaurigashvili avatar rahulawl avatar shenchen93 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alexa-apis-for-nodejs's Issues

Property 'ssml' does not exist on type 'PlainTextOutputSpeech'.

Mocha test won't run:

import { Response, ResponseEnvelope } from 'ask-sdk-model'
const asyncHandler = promisify(handler)
it.only('responds that linking is required for this skill', async () => {
        const result: ResponseEnvelope = await asyncHandler(
          createRequest(
            RequestTypes.Intent,
            Intents.ListSystemCapabilities,
            SkillNames.MyIon,
            undefined
          ),
          null
        )
        console.log('result', JSON.stringify(result, null, 2))
        expect(result.response.outputSpeech.ssml).to.equal(
          '<speak>In order to use this skill, you must first link your account in the Alexa app.</speak>'
        )
      })

Include API documentation on SMAPI SDK types.

SMAPI SDK types don't include much documentation. This introduces friction for developers by requiring they leave the context of the IDE to understand how to use the code. We should make sure to include comprehensive documentation on the types so that developers can jump around the types to learn and understand how it works.

For example, request payloads don't explain the request type or its fields:

/**
 *
 * @interface
 */
interface CreateSkillRequest {
  'vendorId'?: string;
  'manifest'?: v1.skill.Manifest.SkillManifest;
  'hosting'?: v1.skill.AlexaHosted.HostingConfiguration;
}

Functions only describe arguments, not the API:

/**
 *
 * @param {string} catalogId Provides a unique identifier of the catalog
 * @param {string} nextToken When response to this API call is truncated (that is, isTruncated response element value is true), the response also includes the nextToken element. The value of nextToken can be used in the next request as the continuation-token to list the next set of objects. The continuation token is an opaque value that Skill Management API understands. Token has expiry of 24 hours.
 * @param {number} maxResults Sets the maximum number of results returned in the response body. If you want to retrieve fewer than upper limit of 50 results, you can add this parameter to your request. maxResults should not exceed the upper limit. The response might contain fewer results than maxResults, but it will never contain more. If there are additional results that satisfy the search criteria, but these results were not returned, the response contains isTruncated &#x3D; true.
 */
listUploadsForCatalogV0(catalogId: string, nextToken?: string, maxResults?: number): Promise<v0.catalog.upload.ListUploadsResponse>;

Can we re-use the public documentation or do we need more specific documentation for the code?

Incorrect object definition in envelope: interfaces.alexa.experimentation.ExperimentAssignment

The following definition is incorrect.

export namespace interfaces.alexa.experimentation {
    /**
     * Represents the state of an active experiment's assignment
     * @interface
     */
    export interface ExperimentAssignment {
        'id'?: string;
        'treatmentId'?: interfaces.alexa.experimentation.Treatment;
    }
}

What the skill receives looks like:

 "context": {
      "Experimentation": {
        "activeExperiments": [
          {
            "id": "10361395-667c-34f4-b253-4660a29993ae",
            "assignedVariant": {
                "name": "TREATMENT_1"
            }
          }
        ]
      }
    }

Can you please adapt the TS types?

Can't create proactive event due to RelevantAudienceType

Hi,

when creating a proactive event like this:

const relevantAudience = {
	type: 'Multicast',
	payload: {}
};
const now = new Date();
const createEvent = {
	timestamp: now.toISOString(),
	referenceId: 'unique-id-of-this-instance',
	expiryTime: new Date(now.getTime() + 10000).toISOString(),
	event: event,
	localizedAttributes: [{
		locale: 'en-US',
		subject: "visit",
		providerName: "Natalia Fantini has arrived and access was granted.",
		brokerName: "Tribu"
	}],
	relevantAudience
};
const stage = 'DEVELOPMENT';

proactiveClient.createProactiveEvent(createEvent, stage);

I'm getting the following error regarding the relevant audience type.

Argument of type '{ timestamp: string; referenceId: string; expiryTime: string; event: { name: string; payload: { state: { confirmationStatus: string; }; occasion: { occasionType: string; subject: string; provider: { name: string; }; bookingTime: string; broker: { ...; }; }; }; }; localizedAttributes: { ...; }[]; relevantAudience: { ...' is not assignable to parameter of type 'CreateProactiveEventRequest'. The types of ''relevantAudience'['type']' are incompatible between these types. Type 'string' is not assignable to type 'RelevantAudienceType'.ts(2345)

I can't find a way to make this work, I have copied from the example at https://developer.amazon.com/en-US/docs/alexa/alexa-skills-kit-sdk-for-nodejs/call-alexa-service-apis-out-of-session.html Is there a chance this is a bug and string should be accepted as they show in the example?

Thanks!

updateAccountLinkingInfoV1 is not working

the method updateAccountLinkingInfoV1 is not working, the server returns such error:

{
  statusCode: 400,
  body: '{"message":"Account linking information is not valid.","violations":[{"code":"INVALID_REQUEST_PARAMETER","message":"Parsing error due to empty body.","validationDetails":{"originalInstance":{"type":"BODY"},"reason":{"type":"EXPECTED_NOT_EMPTY_VALUE"}}}]}',
  headers: [...]
}

after some investigation, I've found that this method sends the data in the body in the wrong format:

{
  url: 'https://api.amazonalexa.com/v1/skills/.../stages/development/accountLinkingClient',
  method: 'PUT',
  headers: [...],
  body: '{"type":"AUTH_CODE","scopes":[""],"domains":[""],"clientId":"id","clientSecret": "...", "accessTokenUrl":"https://example.com","authorizationUrl":"https://example.com","accessTokenScheme":"HTTP_BASIC","defaultTokenExpirationInSeconds":3600,"skipOnEnablement":false}'
}

but the correct request should contain linking data in the accountLinkingRequest field:

{
  url: 'https://api.amazonalexa.com/v1/skills/.../stages/development/accountLinkingClient',
  method: 'PUT',
  headers: [...],
  body: '{"accountLinkingRequest": {"type":"AUTH_CODE","scopes":[""],"domains":[""],"clientId":"id","clientSecret": "...", "accessTokenUrl":"https://example.com","authorizationUrl":"https://example.com","accessTokenScheme":"HTTP_BASIC","defaultTokenExpirationInSeconds":3600,"skipOnEnablement":false}}'
}

Runtime.UnhandledPromiseRejection is raised when createReminder is called

Recently, in most cases, the following error has started to occur, when I called ReminderManagementServiceClient.createReminder.

Unhandled Promise Rejection

The content of resolved promise is below.

ERROR	Unhandled Promise Rejection	
{
    "errorType": "Runtime.UnhandledPromiseRejection",
    "errorMessage": "ServiceError: Internal Server Error",
    "reason": {
        "errorType": "ServiceError",
        "errorMessage": "Internal Server Error",
        "name": "ServiceError",
        "statusCode": 500,
        "response": "<!doctype html><html lang=\"en\"><head><title>HTTP Status 500 – Internal Server Error</title><style type=\"text/css\">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1><hr class=\"line\" /><p><b>Type</b> Exception Report</p><p><b>Message</b> Servlet execution threw an exception</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><p><b>Exception</b></p><pre>javax.servlet.ServletException: Servlet execution threw an exception\n\tcom.amazon.arest.metrics.ARestQuerylogFilter.doFilter(ARestQuerylogFilter.java:58)\n</pre><p><b>Root Cause</b></p><pre>java.lang.NoSuchMethodError: com.fasterxml.jackson.jaxrs.cfg.AnnotationBundleKey.&lt;init&gt;([Ljava&#47;lang&#47;annotation&#47;Annotation;)V\n\torg.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider$ClassAnnotationKey.&lt;init&gt;(ResteasyJackson2Provider.java:67)\n\torg.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider$ClassAnnotationKey.&lt;init&gt;(ResteasyJackson2Provider.java:59)\n\torg.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.readFrom(ResteasyJackson2Provider.java:101)\n\torg.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:59)\n\torg.jboss.resteasy.core.interception.ServerReaderInterceptorContext.readFrom(ServerReaderInterceptorContext.java:62)\n\torg.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:51)\n\torg.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)\n\torg.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)\n\torg.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:150)\n\torg.jboss.resteasy.core.MethodInjectorImpl.injectArguments(MethodInjectorImpl.java:89)\n\torg.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:112)\n\torg.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)\n\torg.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)\n\torg.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)\n\torg.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)\n\torg.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)\n\torg.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)\n\torg.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)\n\torg.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)\n\tjavax.servlet.http.HttpServlet.service(HttpServlet.java:791)\n\tcom.amazon.arest.metrics.ARestQuerylogFilter.doFilter(ARestQuerylogFilter.java:58)\n</pre><p><b>Note</b> The full stack trace of the root cause is available in the server logs.</p><hr class=\"line\" /><h3>Apache Tomcat/9.0.46</h3></body></html>",
        "stack": [
            "ServiceError: Internal Server Error",
            "    at ReminderManagementServiceClient.<anonymous> (/var/task/node_modules/ask-sdk-model/index.js:219:35)",
            "    at step (/var/task/node_modules/ask-sdk-model/index.js:45:23)",
            "    at Object.next (/var/task/node_modules/ask-sdk-model/index.js:26:53)",
            "    at fulfilled (/var/task/node_modules/ask-sdk-model/index.js:17:58)",
            "    at process._tickCallback (internal/process/next_tick.js:68:7)"
        ]
    },
    "promise": {},
    "stack": [
        "Runtime.UnhandledPromiseRejection: ServiceError: Internal Server Error",
        "    at process.on (/var/runtime/index.js:37:15)",
        "    at process.emit (events.js:198:13)",
        "    at emitPromiseRejectionWarnings (internal/process/promises.js:140:18)",
        "    at process._tickCallback (internal/process/next_tick.js:69:34)"
    ]
}

Create Request sometimes succeeds.

related implement is below.

const client = handlerInput.serviceClientFactory.getReminderManagementServiceClient();
const time = currentIntent.slots.Time;
const t = luxon.DateTime.fromISO(time.value, { zone: userTimezone }).toFormat("yyyy-MM-dd'T'T:00");
const reminderRequest = buildReminderRequest(t, "title");
const reminderResponse = client.createReminder(reminderRequest);
reminderResponse.then((resp) => {
        console.log(resp);
 })

function buildReminderRequest(time, title) {
    return  {
        trigger: {
            "type" : "SCHEDULED_ABSOLUTE",
                    "scheduledTime" : time
            },
            alertInfo: {
                spokenInfo: {
                    content: [{
                        text: title,
                    }],
                },
            },
            pushNotification: {
                status: 'ENABLED',
            },
        };
}

version

dependencies in package.json is below

  "dependencies": {
    "ask-sdk-core": "^2.7.0",
    "ask-sdk-model": "^1.19.0",
    "aws-sdk": "^2.326.0"
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.