Display Charts and Graphs in MS Teams using Microsoft Bot Framework - botframework

I am currently working on a bot built using MS Bot Framework and Ii'm looking for a solution to display charts (i.e. pie charts, etc.) inside MS Teams using Bot Framework. The goal is to get data from a SQL database, process it to form a chart and send it as an attachment or adaptive card to MS Teams.

Your question is a bit vague - I'm not exactly sure what you're asking for exactly, but maybe this can help: I can think of 3 possible ways to do this:
1) Generate your graph programmatically, e.g. in C# (there are a bunch of possibly libraries for this), save it to a temporary location (e.g. Azure blob storage) and then embed the link as a message from the bot
2) same as above, but insert it into an adaptive card (not required, but maybe if you want to send other things like text message etc.
3) Create a Tab to go along with your bot, which is basically a web page you host somewhere, that shows the graph using, for example, a javascript library. The tab appears along the top in the bot's conversation with the user, and you can have an adaptive card with a button that deep links to the tab, for instance.
Which approach you choose might depend on the size of the chart, whether it needs to be interactive, and I'm sure other possible factors. There are also other possible ways to tackle this I'm sure, but these are hopefully some good ideas/starting points.

Related

Chatbot with map/location picker

I am planning to build a chat bot using either azure framework composer, aws lex or google dialogflow but none seem to offer an easy way to have a map/location picker. It should be an straight forward interaction with user where based on a button click the user can then pick the precise location from the map.
Has anyone done something like that?
Many thanks.
I don't believe that any pure NLU framework is going to offer you that level of functionality.
The true purpose behind the likes of Amazon Lex, Google Diaglogflow is to perform intent detection and classification. It is up to the developer to build out the desired functionality associated with each of the configured intents.
What it may practically come down to is presenting the chat user with a map/location popup within the chat widget. The user could then select their current/desired location which gets sent back to the NLU framework for fulfillment.

Customize adaptive card in microsoft bot framework

I am working on microsoft bot framework and I need to style the adaptive cards. But I am facing some challenges because in json file, I am unable to get the styling attribute. So, please suggest how I'll do this.
the style of Adaptive Cards is defined by the App the card is shown in. If you are using Bot Framework for like MS Teams, MS Teams defines the look and feel of a card. In the JSON layout you can select color for a button in terms of "Danger" or "Normal" but the actual color is defined by the host.
If you are showing cards in your own app however, you can define the layout by changing the host config. (see here for details : https://learn.microsoft.com/en-us/adaptive-cards/rendering-cards/host-config)
Only the rendering app can change the styling of cards.
Hope that answers your question.

Cross-platform Text formatting and UI design of messages in Microsoft Bot framework v4

I'm creating pretty complex messages using ms chatbot v4. The cards/messages will need to have text formatting (bold, italic, line breaks, lists, etc), audio, probably an image, you get it, pretty complex.
The goals is to use the bot through several channels like web chat, mobile apps, UWP, facebook, Teams, Slack, etc by azure channel registrations.
I'm a bit confused about which type of card or method to use. Apparently we can use rich cards, adaptive cards, or text formatting (by using *, /n/n, etc). Correct me please if I'm wrong. Microsoft documentations do not guide this directly.
My question is if there is a unified way to create the messages that can work on all platforms or they should be created separately for each family of platforms? In latter case, could you please give me a structured answer or articles?
The Bot Framework gives you the ability to communicate with multiple channels. It "handles the creation of messages that can work on all supported platforms". That being said NOT all platforms support the same UI. Meaning a rich card on Facebook messenger will render differently on Slack or Web Chat. And some channels support more/less features than others. (not all channels support adaptive cards as well)
The bot framework tries its best to support most common features between all channels AND also gives you the ability to send custom Channel Data for each channel if you want to render a specific channel UI component.
So you have to check every channel you want to target (Facebook, Slack, Skype etc.) and see what components their chatbots support.
What I do in big projects is make a "Message Factory" per Channel in which it will handle the creation of the specific channel data for that channel. I use a combination of the Factory design pattern and the Strategy design pattern to implement such structure
Taking Twitter bot as an example,Twitter does not support sending out a Carousel, so in the twitter factory the carousel creation would be an Image + Buttons instead of a rich card. But in the facebook factory, the carousel creation would return a list of rich cards.

How to create dynamic dialogs from REST API in botframework

I wan't to build a bot that gather its answers and questions from a rest API.
Bot: How are you?
User: I'm fine, how are you?
Bot: I'm fine, also.
So the questions from the bot (even the first one) is gathered via REST API from an external service. Also the answer of the user is sent to this service and the Bots answer "I'm fine, also" is the result of a REST request.
I've first implemented it without using dialog feature at all. Works great, but without a dialog it's impossible to finish a dialog.
Looking around for some example I could only find some with WaterfallDialog. WatefallDialogs are build with steps - and I don't know the number of steps.
Is it possible to build such a dialog or isn't botframework not designed for such things?
In bot framework V4, the dialog/conversation flow you pick for conversations is optional, and you don't need to use them (https://learn.microsoft.com/en-us/azure/bot-service/bot-service-design-conversation-flow?view=azure-bot-service-4.0). All you NEED to do is implement bot state (https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-v4-state?view=azure-bot-service-4.0), so you can store either conversation data (or user data - depends on what state you need.)
I implemented conversational flow using a single activity handler and an FSM (https://en.wikipedia.org/wiki/Finite-state_machine) - I use recognizers for common dialogs (help) but for the most part, my transition handler does regex comparisons to extract keywords and then hit the next state. So, if you can graph out your FSM, and list out all your dialog options, you can build a dialog that appears conversational and natural.
I can't share code at this time, but hopefully you don't need it.

Creating an API for LUIS.AI or using .JSON files in order to train the bot for non-technical users

I have a bot that uses .NET, MS Bot Framework and LUIS.ai for its smarts.
All's fine, except that I need to provide a way for non-technical users to train the bot and teach it new things, i.e. new intents in LUIS.ai.
In other words, suppose that right now the bot can answer messages like "hey bot where can i get coffee" and "where can I buy some clothes" with simple phrases containing directions. Non-technical users need to be able to train it to answer "where can I get some food" too.
Here's what I have considered:
Continuing to use LUIS.ai. Doesn't work because LUIS.ai doesn't have an API. The best it has is the GUI to refine existing intents, and the upload app/phrase list feature. The process can be semi-automated if the JSON file with the app can be generated by some application that I write; however, there still needs to be backend code that handles the new intents, and that has to be implemented by a C# coder.
Could it work if I switch from C# to Node.js? Then theoretically I would be able to auto-generate code files / intent handlers.
Azure Bot Service. Seems it doesn't have a non-technical interface and is just a browser-based IDE.
Ditching Bot Framework entirely and using third-party tools such as motion.ai. Doesn't work because there's no "intellect" as the one provided by LUIS.ai.
Using Form Flow that's part of Bot Framework. If my GUI bot builder application can generate JSON files, these files can be used by Bot Framework to build a bot automatically. Doesn't work because there's no intellect as in LUIS.ai.
Keep using Bot Framework, but ditch LUIS and build a separate web service based on a node.js language processing library for determining intents. May or may not work, may be less smart than LUIS, and could be an overkill.
Override the method in LuisDialog that selects the intent from the LuisResponse, in order to use the my own way to decide the intent (but how?).
At this point I'm out of ideas and any pointers will be greatly appreciated.
First of all, LUIS.ai provides an API that you can use to automatize the training. Moreover, here is Luis Trainer written entirely in Python against the API that just does that.
The easiest one, probably is the one you are describing in #1: you can automatize the training (as explaining above) but you will still have to deploy a new version of the bot if new intents are being provided. One thing is letting users to train an existing model with new utteraces and another completely and different thing is to let them create the model :)
It might be hard to skip having to write the backend code (I wouldn't automatize that at all)
Here is a potential idea (not sure if it will work though). You would need 2 Luis models.
One with your current model, that users will be able to train with new utterances.
The second model, is one exclusively intended to be "expanded" with new intents by users.
If you separate this in that way, you might be able to look into a "plugin" architecture for the second LUIS model. So, your app, somehow, loads dinamically an assembly where the second model lives.
Once you you have that in place, you can focus on writing the backend code for your second Luis Model without having to worry about the bot/first model. You should be able to replace the assembly with the second Luis Model and be able in the bot to detect if there is new version of that assembly and replace the current one in the app domain.
As I said, is just an idea as I'm brainstorming with you. Sounds a bit complex, and it's not addressing all your concerns; as you still will need to write code (which in any case, you will eventually have to do)
I am working through a challenge project (training) to automate the creation of Chat Bots specifically targeted against a Luis.ai model using plain old javascript and web services to Luis.
I looked at the Bot Framework and it's just too cumbersome to automate (I want X number of customers to create a Chat Bot without coding). I also want to add my own type of 'Cards' (html widgets) that do more and can be easily configured by someone with zero coding skills.
Calls to the Luis.ai/Cognitive Services API are made in my code behind and the json response returned to my own rules engine. On the following URL click the LUIS API link on the page to open the Luis API Console where you can test, and train your Model. All the endpoints you will need are here...
https://dev.projectoxford.ai/docs/services/
Based on the various endpoints on that page, you can use WebClient in asp.net to pull back the response. So in my testing I have buttons on a page to push utterances up to the model, pull back entities, create hierarchical entities and so on. Have a look at http://onlinebotbuilder.com to see how an intent of product dynamically inserted a shopping cart.
When your tool is built and utterances start to arrive, Luis.ai will store them and via the Suggest tab (at Luis.ai) it will ask you for guidance...Unfortunately I don't think you could give that control over to your customers, unless they are experts in your domain (they understand which utterance belongs to which intent). You don't need to take your app down, just train it periodically to improve the Model based on your customers input...soon enough you will have your model working well based on your intents.
Hope that helps.

Resources