Capture Alexa response json - aws-lambda

I would like to capture Alexa response and do some processing outside AWS Lambda. Maybe a view I would like to create with bar charts and on update it at runtime based on Alexa response. How should I do that? I can create an independent Alexa working skill.

From AWS Lambda, you need to make an HTTP Post request to your website where your bar chart is served so that you can update your bar chart.
In order to post the response of the user, you need have an intent and then capture the user's response via slots.

I am assuming you are using Node.JS for the implementation of skill, otherwise you can find similar section of documentation for the language of your choice.
You can leverage Response Interceptor for your purpose. Follow this link:
https://ask-sdk-for-nodejs.readthedocs.io/en/latest/Request-Processing.html#request-and-response-interceptors
In response interceptor you will get your response object which you can se

Related

Slack - Interactive button with authentication

What I'm trying to accomplish?
Send an API (chat.postMessage) from a 3rd party app to a Slack user - Done
The message will have two buttons (approve and decline) which the user can click on - Done
Upon clicking on one of the buttons, Slack should send an API back to the 3rd party app - TBD
Before sending an API, Slack should retrieve an authentication token via API - TBD
Note: I've seen in Slack docs mentioning of /incoming endpoint (also /interactive-message). My 3rd party app has a strict set of available APIs. I'm not able to create new API endpoints. Also, I need the payload to be sent in a specific JSON structure.
I've reviewed Slack documentation but I can't figure it out.
Making notifications actionable
I'm technical but not a developer so there might be nuances which I'm missing.
Is there any section in Slack where I can add custom code to accomplish such integration?
If not, how I can accomplish it?
Edit:
I've configured a Request URL (in slack), when I click on one of the buttons in the message, I can see an API request is being sent to the URL.
I'm able to see the payload as well.
My problem is that I need the information to be sent in a different format and to a different endpoint.
What is the best approach to take for this? Do I need to develop a new service to capture and parse the payload and then generate the API request to my 3rd party app?
Ok, so here is how I've accomplished it.
Upon clicking a button in slack, Slack sends an API with a certain payload to the predefined endpoint which you configure (Request URL).
I've used free tier AWS serverless components:
API Gateway and Lambda
API gateway receives the payload and invokes the Lambda function (I used Python as it seems the easier for a non developer)
My Lambda function is processing the payload and has the logic to interact with my 3rd party app in the required way.

Single Sign On(-ish) behavior from MS Teams with BotFramework Composer

We are using BotFramework Composer to create bots. These bots are supposed to get information from a backend REST service, where we need to know, which user is submitting the request for data. We are currently using {turn.activity.from.id} to get the Teams user's id, and sending it in a special http header in the "Send an HTTP request" action. We then perform a mapping of this id to our internal users.
We are, of course, aware, that this is not secure at all, since anyone who knows this, could get the user's id and send it to our service. We are currently thinking along the lines of generating a short-lived jwt token in the Bot to send to our application. However, we see no direct way of implementing this token generation in the Bot Framework Composer itself.
Also, we don't want to use OAuth, because we don't want the user to have to log in via the bot.
Is there a way to implement custom token generation using C# or js and assigning it to a dialog variable to be used in a "Send an HTTP request" action?
This document discusses how to implement an HTTP request in Composer. The first half is focused on creating a login for OAuth, which I know is not your focus, so look at the second half. If you set up a simple server that can generate a token for you, then you can make a request to it from Composer using the method described.
As links can break and docs can change (and Composer is still in Preview), I would recommend saving the doc somewhere and checking back every so often for any updates.
I've used HTTP requests from within Composer, myself, so I know this will work for you.
Hope of help!
You can create a custom Action or a package component and create any c# methods there for JWT generation. This will keep it all local to the bot.
https://learn.microsoft.com/en-us/composer/how-to-create-custom-actions

Is it possible to trigger TravisCI build by Slack message w/o spinning up my own server?

When I did research online, most of the solutions are about triggering Slack notification from TravisCI. Now I want to do the reverse direction - type some message in slack, and trigger a build task in TravisCI.
I'm looking at Slack's Outgoing WebHooks - under their "Custom Integrations" in Slack app directory. However, their webhook POST data spec is fixed, not seem to be programmable through just their webpage UI. They have a column in the UI that lets you fill in URL(s) to POST to. But I don't see any ways that I can customize the data field of the POST request.
Same as TravisCI's Triggering Builds API v3, the data fields they expect in the POST are fixed and unchangeable.
I know I can sign up a cloud service, write some code and spin up a server to re-package the parameters to do the work, like a middleware between these 2 APIs. But just want to see if anyone manages to achieve triggering TravisCI by Slack in such way that doesn't involve spinning up a server myself?
I ended up hosting a server and writing the porting logic myself. I guess there's no simple way to do this, after all they are different APIs. Here is the code where I request against travisCI API, and here is the code where I unpack the slack webhook POST request.

Dialogflow Webhook C# integration

What is the Dialogflow webhook format? I want to capture the data in an MVC controller and then respond to the webhook whilst maintaining context. How do I do this in C# with the Dialogflow v2 client library? I haven't found any examples to follow in this language and am unsure how to capture the data.
You can read more about Dialogflow webhook format here. Regarding the Dialoglow v2 client library, it is specifically stating that you don't need to use it and can answer in JSON instead using JObject.
If you want to use Protobuf to lower the overhead and save some traffic you will have to use utilities from idiomatic cloud libraries described in the previous link.
The "Dialogflow V2 client library" is for people who are writing clients that send requests to Dialogflow. Dialogflow calls this a "Detect Intent Request", since you're sending a text string (or audio stream) to Dialogflow and it will determine and process the Intent.
If you're interested in building a Fulfillment webhook that is called when an Intent is matched, then you want to look at the Dialogflow Fulfillment API, which is different. There is no supported library for C# yet, but you can parse and return the JSON. The JSON for V1 and V2 are slightly different (mostly in the names of the fields used, but also occasionally in what the values should be).
You can see the fields for the JSON as well as several examples of the request and response formats. There was also an article on Medium recently posted by a Google Developer Relations member discussing using C# for fulfillment in Dialogflow.

How to add custom fields in json response directive of Alexa custom skill?

I have integrated Alexa Voice Services into my WPF application. Idea is to provide VUI to application. For this I am creating a Lambda function for handling request and to send response back to application. But problem is I am not able to implement or add some of custom fields in Json response so that I can manipulate my application based on that fields.
Is there any way to add custom field to Json response or any other way to archive it?
Thanks.

Resources