I am working on developing a web service which is used to Handling Requests Sent by Alexa and respond back with specific response in .net framework. The request body sent by Alexa to your service in JSON format like below :
{
"version": "string",
"session": {
"new": true,
"sessionId": "string",
"application": {
"applicationId": "string"
},
"attributes": {
"string": {}
},
"user": {
"userId": "string",
"accessToken": "string"
}
},
"context": {
"System": {
"application": {
"applicationId": "string"
},
"user": {
"userId": "string",
"accessToken": "string"
},
"device": {
"supportedInterfaces": {
"AudioPlayer": {}
}
}
},
"AudioPlayer": {
"token": "string",
"offsetInMilliseconds": 0,
"playerActivity": "string"
}
},
"request": {}
}
and Response Body Syntax in Json format below:
{
"version": "string",
"sessionAttributes": {
"string": object
},
"response": {
"outputSpeech": {
"type": "string",
"text": "string",
"ssml": "string"
},
"card": {
"type": "string",
"title": "string",
"content": "string",
"text": "string",
"image": {
"smallImageUrl": "string",
"largeImageUrl": "string"
}
},
"reprompt": {
"outputSpeech": {
"type": "string",
"text": "string",
"ssml": "string"
}
},
"directives": [
{
"type": "string",
"playBehavior": "string",
"audioItem": {
"stream": {
"token": "string",
"url": "string",
"offsetInMilliseconds": 0
}
}
}
],
"shouldEndSession": boolean
}
}
I researched on Amazon Developer Forum Hosting a Custom Skill as a Web Service , Handling Requests Sent by Alexabut i am not able to achieve this thing and one thing i am not using Lambda function i want to make a custom skill and my location is not in North US.
I got the Lib. from github here and used in my web service but not able to sync with this library, anyone here to give me a direction how can i do this or how can i started thanks in advance.
I've just published a project that uses the same AlexaSkillsKit.NET package that you mention. The goal is to help everyone create Alexa Custom Skills using .NET + Visual Studio that you can easily deploy to Azure.
https://github.com/tamhinsf/Azure4Alexa
There's a sample skill implementation that you can use as a pattern for your own Custom Skill. It makes use of httpClient and the usual async patterns.
Just download and fire up Visual Studio to get started!
It's been some time that the last answer was written, plus the example which Azure4Alexa sample implements, uses deprecated base classes, for cases where you might want to use the 'context' part of your Alexa request, you would want to implement SpeechletBase, ISpeechWithContext in your final Speechlet class.
To be honest, I know the README.md on AlexaSkillsKit.net is very dense, but if you do give it some time, and go through the AlexaSkillsKit.Sample project, and go through the definitions of the implemented base classes, you will understand the request handling through and through.
Let me also take this opportunity to breakdown how I understand the classes and their structures:
SampleSessionSpeechlet Class - Is just the final class that Logs your request, and implements the ISpecchletWithContext(which mandates the implementation of OnSessionStarted(), OnLaunch(), OnIntent() & OnSessionEnded()) these four functions are basically handlers of all the requests that Alexa can send to your Web Service.
SpecchletBase Class - Basically Wraps around the SpeechletService Class which actually does the all heavy lifting.
SpeechletService Class - You basically call its GetResponseAsync()(which the SpeechletSerive's GetResponse() wraps) which takes the passed Alexa Request, parses it into a cute little dataClass called SpeechletRequestEnvelope, does session management, passes the SpeechletRequestEnvelope to your your implementation of the OnSessionStarted(), OnLaunch(), OnIntent() or OnSessionEnded() methods, gets your returned objects and Returns your Alexa Response as a class called the SpeechletResponseEnvelope
Hope that helps with some quick implementation, but I highly recommend going through the Lib directory and understand how things work. And who knows? Contribute!
Related
I'm running out of time to get this done, but I just can't seem to find my issue.
I'm trying to deploy an ARM template that creates a new MCA subscription. The template works when deployed via Azure PowerShell, but when using the Azure SDK it gives the following error:
Microsoft.Rest.Azure.CloudException: 'Deployment template validation failed: 'The resource 'Microsoft.Subscription/aliases/devtestdeployasp22' referenced in output is not defined in the template. Please specify resource identifier and api version if the resource is outside of the template. Please see https://aka.ms/arm-template-expressions/#reference for usage details.'.'
var subscription = azure.Deployments
.Define("deployment_temp")
.WithNewResourceGroup("temprg", Region.USEast)
.WithTemplate(Utils.GetArmTemplate("<path_to_file_removed_for_privacy>"))
.WithParameters("{}")
.WithMode(Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentMode.Incremental)
.Create();
The template used with this contains:
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subscriptionAliasName": {
"type": "string",
"metadata": {
"description": "Provide a name for the alias. This name will also be the display name of the subscription."
}
},
"billingScope": {
"type": "string",
"defaultValue": "<Removed>",
"metadata": {
"description": "Provide the full resource ID of billing scope to use for subscription creation."
}
},
"mgName": {
"type": "string",
"defaultValue": "mg-mission-default-dev",
"metadata": {
"description": "management group name"
}
}
},
"variables": {
"mgId": "[concat('Microsoft.Management/managementGroups/',parameters('mgName'))]"
},
"resources": [
{
"scope": "[variables('mgId')]",
"name": "[parameters('subscriptionAliasName')]",
"type": "Microsoft.Subscription/aliases",
"apiVersion": "2021-04-01",
"properties": {
"workLoad": "Production",
"displayName": "[parameters('subscriptionAliasName')]",
"billingScope": "[parameters('billingScope')]"
}
}
],
"outputs": {
"subscriptionID": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Subscription/aliases', parameters('subscriptionAliasName'))).subscriptionId]"
}
}
}
Any help would be appreciated, or even an alternate path I could take but the goal is to create a new MCA subscription (with some resources) using C#.
You need to fetch the Subscription ID by using tenantResourceId -
tenantResourceId - Returns the unique identifier for a resource deployed at the tenant level.
"outputs": {
"subscriptionId": {
"type": "string",
"value": "[reference(tenantResourceId('Microsoft.Subscription/aliases', parameters('subscriptionAliasName'))).subscriptionId]"
}
}
Please refer this documentation.
I am trying to automate some processes in our organization and part of that includes being able to transfer a repository in one of our azure devops organizations to another (think of it as a dev organization and a test organization so we are pushing from dev to test)
Through the API https://learn.microsoft.com/en-us/rest/api/azure/devops/git/import%20requests/create?view=azure-devops-rest-6.0 I am trying to create an import request.
Here's where I'm stumped and the documentation doesn't say much about.
If I use a request body like in the example:
{
"parameters": {
"gitSource": {
"url": "https://github.com/Microsoft/vsts-agent.git"
}
}
}
The import request works fine as long as I'm importing to an empty repository. However I need to be able to sync an existing repository.
[There's a property in the documentation called overwrite that seems to be for this purpose][1]: https://i.stack.imgur.com/ezCB3.png
The only problem is when I add this to the request body and set to true
{
"parameters": {
"gitSource": {
"url": "https://github.com/Microsoft/vsts-agent.git",
"overwrite": true
}
}
}
I get bad request message saying invalid combination of parameters
If I set this to false it works if I'm trying to import to an empty repository. If the repository isn't empty I get an error saying I can only import into an empty repo.
So it seems this property is meant for exactly what I'm doing, however it seems there are more parameters needed when that property is set to true in order to make the request succeed, but the documentation is lacking in this area.
Any help would be much appreciated
I suspect that overwrite = true is giving you error because there may be some permission issues or Auth problem in your latter repo.
Alternatively, you can fork your parent repository and sync only the provided refs:
CURL:
POST https://dev.azure.com/{organization}/_apis/git/repositories?sourceRef=users/heads/master&api-version=6.0
Request Body:
{
"name": "forkRepositoryWithOnlySourceRef",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90"
},
"parentRepository": {
"id": "76b510af-7910-4a96-9902-b978d6226bee"
}
}
Sample response (HTTP 201):
{
"id": "29230c30-9125-459b-a3f6-ffab329053bd",
"name": "forkRepositoryWithOnlySourceRef",
"url": "https://dev.azure.com/fabrikam/MyFirstProject/_apis/git/repositories/29230c30-9125-459b-a3f6-ffab329053bd",
"project": {
"id": "3b046b6a-d070-4cd5-ad59-2eace5d05b90",
"name": "MyFirstProject",
"url": "https://dev.azure.com/fabrikam/_apis/projects/3b046b6a-d070-4cd5-ad59-2eace5d05b90",
"state": "wellFormed",
"revision": 12,
"visibility": "private",
"defaultTeamImageUrl": null
},
"size": 0,
"remoteUrl": "https://dev.azure.com/fabrikam/MyFirstProject/_git/forkRepositoryWithOnlySourceRef",
"sshUrl": "git#ssh.dev.azure.com:v3/fabrikam/MyFirstProject/forkRepositoryWithOnlySourceRef",
"isFork": true,
"_links": {
"forkSyncOperation": {
"href": "https://dev.azure.com/fabrikam/_apis/git/repositories/29230c30-9125-459b-a3f6-ffab329053bd/forkSyncRequests/7"
}
}
}
The error that I'm seeing is that as soon as I enter something into a Parameter on the UI it disappears.
I am creating Controllers on the fly based on method decorations, so I can't create the XML that drives swagger.json at build-time. As a way around it, I created another controller which inspects the controllers that were added to the runtime and outputs valid swagger.json (or so I think). This works okay with POST, but seems fails peculiarly when trying to add route parameters to GET.
This is the json I generate for my GET:
"openapi": "3.0.1",
... // cutting out unrelated other stuff
"/api/v1/test4/{Value2}": {
"get": {
"tags": [
],
"summary": "A sample GET",
"parameters": [
{
"name": "Value2",
"in ": "path",
"required": true,
"schema": {
"type": "string",
"format": ""
}
},
,
],
"responses": {
"200": {
"description": "Success",
"content": {
"application/json": {
"$ref": "#/components/schemas/TestReply"
}
}
}
}
}
}
}
The project is a .Net Framework 4.8 one, and the packages I'm using are Microsoft.AspNetCore 2.2.0 and Swashbuckle.AspNetCore 5.5.1.
There's an extra space in the name of the in attribute:
"in ": "path",
^
^
Remove that space.
You can also use https://editor.swagger.io to check your API definition for syntax errors.
I am having a hard time figuring out what would be the correct Swagger 2.0 spec for the case where I am expecting a parameter in the query to be a list of long (C#). This is what I tried based on seeing examples where the parameter being passed in query is simple datatypes like int or boolean. But this does not seem to work. It does not look like it is getting parsed correctly.
My URI is somethng like this :
https://.../testinstance/FeatureTexts?api-version=2016-09-13&featureIds=1629988727&featureIds=1924980024
And in my API-level test it does not gets resolved to anything similar after the part api-version=2016-09-13&featureIds=
"get": {
"tags": [
"FeatureText"
],
"operationId": "RenderFeatureTexts",
"description": "The operation to get feature texts for specified features",
"parameters": [
{
"name": "featureIds",
"in": "query",
"required": true,
"schema": {
"type": "array",
"collectionFormat": "multi",
"items": {
"type": "integer",
"format": "int64"
}
},
.......
C# code generated by Swagger Codegen:
public static async System.Threading.Tasks.Task<object> ListFeatureTextsAsync(this IAgentClient operations, object featureIds, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
using (var _result = await operations.ListFeatureTextsWithHttpMessagesAsync(featureIds, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
Change the parameter definition as shown below, that is, move type, items and collectionFormat out of schema. In OpenAPI 2.0, schema is only used for body parameters, and other parameter types use type etc. directly.
"parameters": [
{
"name": "featureIds",
"in": "query",
"required": true,
"type": "array",
"collectionFormat": "multi",
"items": {
"type": "integer",
"format": "int64"
}
You can easily catch syntax errors like this by pasting your spec into Swagger Editor.
My query goes like this: If I have a feedItem (an image posted on facebook), how can I verify that I have liked it or not? Can I verify all the interactions which I have done to the feedItem or the interactions other people have done to it (like, dislike, pin, share)? Is there any way in getstream.io to retrieve these interactions?
Thanks in advance...
Graph API provides all functions you need. Here are some examples:
Read shares[it's a field of an object]: https://developers.facebook.com/docs/graph-api/reference/v3.1/post#read
Read Shared posts: https://developers.facebook.com/docs/graph-api/reference/v3.1/object/sharedposts
read likes:
https://developers.facebook.com/docs/graph-api/reference/v3.1/object/likes#read
/likes returns only the profile for the current user if read with a
user access token:
Album, Photo, Post, Video
all returns are JSON, which you can directly Deserialize Anonymous Type without using stream, for example, likes:
{
"likes": {
"data": [
{
"name": "Bill the Cat",
"id": "155111347875779",
"created_time": "2017-06-18T18:21:04+0000"
},
{
"name": "Calvin and Hobbes",
"id": "257573197608192",
"created_time": "2017-06-18T18:21:02+0000"
},
{
"name": "Berkeley Breathed's Bloom County",
"id": "108793262484769",
"created_time": "2017-06-18T18:20:58+0000"
}
],
"paging": {
"cursors": {
"before": "Nzc0Njg0MTQ3OAZDZD",
"after": "NTcxODc1ODk2NgZDZD"
},
"next": "https://graph.facebook.com/vX.X/me/likes?access_token=user-access-token&pretty=0&summary=true&limit=25&after=NTcxODc1ODk2NgZDZD"
},
"summary": {
"total_count": 136
}
},
"id": "user-id"
}