Azure Bot - communicate through REST APIs - node.js

I have to integrate 2 different azure bots into a single azure bot application. So thinking of integrating with the REST api. Will this approach work ?
From this links
https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-quickstart?view=azure-bot-service-4.0
https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-api-reference?view=azure-bot-service-4.0
I can get the access token from cloud bot. But there is no example on "sending message from client". It have examples on handling client messages from server as Activity object.
It would be better if any samples on "sending message from client to azure cloud throught REST"
what is different between REST and connectors.?
I believe it will be possible with DirectLine, but wanted to know how to do thorugh REST APIs.
Thanks in Advance !!

I can't tell you whether or not your idea will work for dealing with two separate bots without more information. If you are trying to start conversations with both bots and the sending messages to the different conversations based on some set of criteria than that should work.
The Bot Framework API can essentially split into two sections:
The Connector (primary) API that the bot uses to talk to users and the service.
The DirectLine API that you can use to talk to the bot instead of using one of the built-in connectors like Slack or Teams.
Based on your needs, the DirectLine is indeed what you are looking for. The directline.botframework.com/v3/directline/conversations/abc123/activities endpoint will allow a client app to send a message to the connected bot.

Related

Send a Google Chat message from a regular account (not a bot)?

I'm trying to send a notification out using Google Chats. But I have a few problems with the documentation I've been able to find:
It requires me to have a paid service account, which I do not have, and will not be getting
It requires using a chat bot, which (in my understanding) needs to be added to a room, and cannot just send out messages
Chat bots can't send out messages directly to personal accounts?
I'm already using Google OAuth2 authentication to access another Google API, so I'd like to use a Google API to send messages directly from the authenticated account. How would I do that?
So far:
All the documentation I can find is about making a chat bot.
I've considered some alternatives to sending out messages, but due to corporate device restrictions that will not be changing, google chats is my best option.
At the moment what you're trying to do is not possible, for multiple reasons.
You may know this already, but Google Chat is an upgrade to their old "Classic Hangouts" chat. In Google's own words, this is focused on enterprise (i.e. paid) accounts. While personal accounts are also able to upgrade and get some of the benefits, their documentation shows that Google Chat for personal accounts is very similar to the old Hangouts and most of the new features are meant for the paid accounts. This also includes the use of bots.
As you've observed, the Chat API currently only has methods to create and manage bots. There are no methods to send messages as your own account. This could be to prevent spam or because their Chat API is relatively new, since the Classic Hangouts did not have an API, and Chat hasn't fully replaced it yet. Even then, given that Chat is "enterprise-focused", it is uncertain whether or not personal accounts would get access to any new API features.
You could try to post feedback on their issue tracker or request the feature to see if you get a response, but for an immediate solution you may want to just use the Gmail API to send a regular email or reconsider the other alternatives that you had in mind.

Microsoft Teams - Bot Health Check

I want to implement a health check on my MS Teams bot but it seems that support for that was removed on https://github.com/microsoft/botframework-sdk/issues/6225.
What is the best approach now to add a health check to my bot?
Thanks
There is no mechanism built into the Bot Framework SDK to accomplish this. You'd need to setup an API route in the bot, and have the other service call that endpoint. Depending on your security considerations you'd probably also want to authenticate that call in some manner.
At the end of the day, the bot is just a web service using some specialized API calls to model conversations - you can add any additional APIs you like just as you would with any other web service.

What is Direct Line in Azure?

I am starting to develop a bot for Teams and I do not understand the various channel offerings. I know I need to add Microsoft Teams to the channel list in Azure for the bot to be able to message people through chat channels, but I can't figure out how to allow the bot to communicate with an API that is hosted in AWS. Maybe Direct Line is what I'm supposed to use, but the documentation is very unclear. Here is what I can find about Direct Line:
Direct Line. This is the standard channel offering of Direct Line. It works by default with bot templates via the Azure portal, bots from the Bot Builder Samples, and bots created with the Azure CLI. This is the Direct Line best suited in the majority of the cases. See Connect a bot to Direct Line.
If anything, I became more confused after reading that. It raises more questions than it answered. If Direct Line is supposed to allow me to communicate with third-party APIs, I don't know how to get started even if I enable it. The BotBuilder repository documentation does not mention Direct Line channels, at least not in an obvious way, so that hasn't been much help either.
I have very little clue about how this works even though I spent my whole day reading about it. Deploying a bot to Teams that can make a call to another API is much more difficult than I anticipated. All I want to do is say #bot command and have it call an API to make a GET request. Once I am able to do that, I will be able to develop the rest of the application, but using the requests module in Python has not worked and I don't know why.
Anything you can offer about how this should work would be greatly appreciated.
Direct Line, as the name implies, is a direct line of communication to an Azure bot. Essentially, it is a set of APIs that you can use to communicate with an Azure Bot outside the set of provided channels. If you are building a custom application that none of the other channels such as Web Chat, Teams, Email, etc. would be appropriate for, then you can use the Direct Line API to send and receive messages to and from a hosted bot with REST calls. The API reference in the documentation explains how to connect to and use Direct Line. You would implement these calls into your application as you would calls to any other REST API and display the responses in whatever manner fits your use case.
The key intuition here is that Direct Line is only for communicating with the bot. It has nothing to do with connecting to outside services. Communicating with 3rd party services would be accomplished in the same manner as any other application. I don't know how you've implemented your application or what service you're connecting to, but I would suggest you double check that your calls to that service work outside your bot using Postman or curl before attempting to implement them into the bot.
Your use case would appear to be the Microsoft Teams channel, and not Direct Line.
I'm not totally clear either on what Direct Line is for, but from what I can understand it would be if you want to include a bot experience in your own custom app, like a desktop app with a "chat" feature. It's definitely not needed for Teams though - you only need the Teams channel.
With regards calling an API from within your bot, essentially your bot is just a standard web service - it can do anything any other kind of web service / web api can do, e.g. calling a 3rd party API.

How to get and pass user conversation data to backend API in Azure Bot Framework Composer v1.4.0?

I am new to Azure Bot Framework Composer.
I am creating chatbot using Azure Bot Framework Composer(without writing code) which need to be launch in Angular Web Application from Azure Cloud after deployment.
In my chatbot project, need to fetch the user conversation data and send it to backend API from Azure Bot Framework Composer.
How to achieve this?, anyone help on this.
You can view the conversation data using ${conversation} scope and from dialog stack can access required information. To get last conversation data can use ${turn.Activity}. For sending to backend API, create HTTP post method and pass the data in the body of your request.
Without knowing more details on your chatbot project, one reasonable approach to take is to use the Send HTTP Request action in the composer.
After you obtain the values from the conversation that you are looking for, (can be stored in conversation / dialog variables), you could then pass it onto an HTTP send request and deliver that to your backend API.
With this, you can send any payload to your backend API.

How to get conversation details in microsoft bot framework for skype?

I'm able to get conversation details for webchat using https://webchat.botframework.com/api/conversations/[conversationId]/messages
Service URL for skype channel is https://skype.botframework.com, but I dont find any documentation for getting conversation details
You can use the DirectLine Rest API (see docs).
The Direct Line API is a simple REST API for connecting directly to a single bot. This API is intended for developers writing their own client applications, web chat controls, mobile apps, or service-to-service applications that will talk to their bot.
Within the Direct Line API, you will find:
An authentication mechanism using standard secret/token patterns
The ability to send messages from your client to your bot via an HTTP POST message
The ability to receive messages by polling HTTP GET
A stable schema, even if your bot changes its protocol version
You need to enable the DirectLine channel for your bot on (see screenshot)
You don't have to access each specific channel endpoint separately, you can do it all (with some limitations) through the DirectLine API.
Start a New Conversation
POST /api/conversations
Get Messages in a Conversation
GET /api/conversations/{conversationId}/messages
Send a Message
POST /api/conversations/{conversationId}/messages
The full details are in the docs as linked above.
Hope this helps
Can you be more specific about conversation details and what you're looking for?
Generally, you shouldn't assume those URL's are static BTW; an incoming message from the Bot Framework will have a ServiceURL that should be used for the life of that conversation. Some services may have multiple ServiceUrl's that they give out for different users.

Resources