Writing A Bot Framework Client - botframework

I've been away from BotFramework development for a while and have now come back to it.
I am using this Bot hosted internally within my company, and talking to it using a relay application using REST. This all worked fine.
However, after updating to V3 of the Bot Framework I came across issues. I see that the changes mean that the Bot now replies asynchronously, sending data to the ServiceURL field. Therefore I have a couple of questions.
Can I still use this architecture for the Bot Framework? (i.e. hosting internally to the company, without using Azure or Connectors)
If I can, I assume that my relay application will need to have an endpoint that the Bot can reply to? Does it just do a http POST to the ServiceUrl I give it? (i.e. http://mybotserver:9000) or is it posting to a URL under that server address? I assume the body of the post is the usual Json you see in the Channel Emulator.

I don't know the specifics of your architecture, but in general, if your bot (via relay) can:
Reach the ServiceURL endpoint with an https post
Receive incoming requests to an endpoint you registered with the Bot Framework
The relay needs to be able to reach our login service to sign requests
Also needs to be able to reach our OpenId endpoint as part of signing/authenticating
That should be it.

Related

Outlook addin - js or api generate email file

I have an outlook addin that I've built using Yeoman. The addin communicates with a server API on my server to combine data from an email with additional data from a database that a user has saved against an email address. This is all working great.
Next I want to store a copy of the email server side, as a file on disk, .msg preferred but I'll take a .eml if thats the only option.
I have 2 options but don't know if either are possible. Either the addin generates the .msg file and posts it to the server API OR the server side API generates the .msg file directly. I have got the server side using the Outlook v2 API and able to pull back the email information when the client passes it the token, id etc. If it could just generate/download a .msg file server side this would be ideal.
As a side note, many of the Microsoft API pages point out the deprecation of the Outlook API in favor of the Graph API, however there are inconsistent links between the pages and it get confusing. I have discovered the token from getCallbackTokenAsync only works with the Outlook API and not Graph, but I cant find out a way to generate a graph compatible token. All the example code from MS uses Office.context.mailbox.restUrl which still gives the Outlook API url and not Graph!
So I guess I'm trying to find out if it's even possible to get/generate a .msg or .eml file either client side using outlook.js or server side using one of the api's. Thank you.
I can get message data both client and server side but cannot get a physical email file.
The Office JavaScript API (OfficeJS) doesn't provide anything for saving messages as msg files (or getting streams). The best what you could do is to use Graph API where you could get the EML file, see Get MIME content of a message for more information.
The server-side code may use the OAuth 2.0 On-Behalf-Of flow (OBO) to request a new access token with permissions to Microsoft Graph. Read more about that in the Authorize to Microsoft Graph with SSO article.
The on-behalf-of (OBO) flow describes the scenario of a web API using an identity other than its own to call another web API. Referred to as delegation in OAuth, the intent is to pass a user's identity and permissions through the request chain.
For the middle-tier service to make authenticated requests to the downstream service, it needs to secure an access token from the Microsoft identity platform. It only uses delegated scopes and not application roles. Roles remain attached to the principal (the user) and never to the application operating on the user's behalf. This occurs to prevent the user gaining permission to resources they shouldn't have access to. See Microsoft identity platform and OAuth 2.0 On-Behalf-Of flow for more information.
Eugene's answer is good. If ultimately you need to get that message to your backend service, using Graph as Eugune described would be the recommended approach. If for whatever reason you are still looking for a capability to access it on client using Office.js, it is not a part of the product. We track Outlook add-in feature requests on our Tech Community Page. Please submit your request there and choose the appropriate label(s). Feature requests on Tech Community are considered, when we go through our planning process. Note there is already a couple of similar ideas there, if you search for "eml" keyword, that you may want to upvote.

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.

Integrate LiveAgent with MS BotFramework (NodeJS)?

I have a problem in integrating LiveAgent (A customer support/ticketing web application) and MS BotFramework.
The botframework in Azure works fine and ready to integrate with it.
Here are what I guessed/supposed to be the architecture
LiveAgent will do a HTTP POST (they have API for that) to MS Azure Bot Endpoint (NodeJS Application - like: https://<ms_azure_link>/api/messages)
When Azure receives the POST, it will match the intent, running the normal dialogflow, and return necessary response (text, hero card, image etc.), until the end of conversation.
Here are my questions:
When LiveAgent wants to connect to Azure, which endpoint should be used? The api/messages or something called DirectLine API 3.0?
Actually the DirectLine API will return something like this:
{
"conversationId": "3M3TeaDtc3uArxXwlna7AG",
"token": "<My token>",
"expires_in": 1800,
"streamUrl": "wss://directline.botframework.com/v3/directline/conversations/3M3TeaDtc3uArxXwlna7AG/stream?watermark=-&t=ubeJVCXqb9I.dAA.MwBNADMAVABlAGEARAB0AGMAMwB1AEEAcgB4AFgAdwBsAG4AYQA3AEEARwA.7UpMr6Tm0wE.9RmCM_XyjII.CQbU7viSec2P7CtznrijQwou0A8N0GynOvnsUmNT04o",
"referenceGrammarId": "669c7246-bc5c-f25f-aae7-0ad7f39e25b4"
}
As you can see, after you connect using DirectLine, you need to proceed using WebSocket.
So how to connect to this WebSocket thing using LiveAgent? For your information, LiveAgent only suppots HTTP GET/POST to custom URL.
If we don't use DirectLine API, that I will use MS Azure Bot Endpoint.. Now the question becomes: what should be passed to this endpoint so that LiveAgent can authorize itself and using the Bot as usual? Any example on that? DirectLine API Example seems not talking about this.
Thank you very much in advance. I know that this question may not be illustrated well but, hope that you can understand.
If you have any question, please let me know, I am glad to clarify that.
Thank you very much again for all your help.
If you want to treat LiveAgent as a bot client and to make some request against to your bot application. We suggust you to leverage DirectLine APIs.
To implement with DirectLine API via Node.js, you can start with the sample at https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-DirectLine/DirectLineClient
Specially to your second question, to keep a conversation with bot, the web socket stream is not required, unless you want to Receive activities via WebSocket stream
You can refer to the code block from the official DL code sample, which doesn't keep the web socket stream, and only leverage the conversationId and token to make HTTP requests against to bot application.
We did similar solution using MS BOT Chat SDK without DirectLine using windows selfservicehost service. We are interface from left side to MS BOT and to another CRM from right side. When do you say LiveAgent - is it Salesforce solution?

Endpoint URL has an invalid value

I am trying to register my Bot at https://dev.botframework.com
However, when I put https://localhost:44338/api/messages in the
Messaging endpoint field I get an error - Endpoint URL has an invalid
value. My bot is running locally on https://localhost:44338.
Also is there any way I can create my own web client which can
communicate with my Bot.
Is Bot Registration mandatory for it to be deployed in production.
It looks like you're trying to register your bot with your local instance whereas you need to use a deployed (production) instance.
Publish your bot to Azure and use the URL you get from that. In Visual Studio you can right click your project and select "Publish"- just follow the instructions from there.
You can make your own client, yes. You can use your browser or anything else to make HTTP requests to your production bot.
You need to register your bot if you're using the bot connector.
Hope that helps.

Api and consumer flow

I am developing an API for a social network website. This API will basically get all the requests from the users (get friend list, post a status update etc) and reply back if necessary.
We will implement OAuth 2.0 protocol for authentication. Consumer (our php project) has API id and secret.
Basic scenario:
Client wants to log in
API Consumer (php web project) takes this request, directs user to API
User send his/her user credentials to the api, gets the token.
User comes back to our website, pass token to the consumer.
Consumer goes to the api server, gets the access token.
Now consumer (php project) has access to user's private information.
Since this is a social network website, we want app developers to be able to use our API in the future.
I am not experienced in API-design. Does that flow make sense? I guess the simplest authentication would be accessing user information through php project. But we don't want to access database in php code. We will use ajax in client side and send a request to the API. And I believe there should be a better solution, what would you suggest?
Sure, API design is basically point where you need to choose technology.
Either it can be PHP or .net or Java.
I would prefer either PHP or .Net as we get lot of flexibility in it.
API will return XML or Json depending upon the request.
There are lot of CMS in php which can be helped.
.net we have Service Stack to help you.
API's had to be fully independent from other world as well as within API method as well.
If you are able to achieve this, then you will surely create a good architecture.

Resources