AI at a fingertips with Microsoft Azure Cognitive Services & Azure Machine Learning

Hi,

Today, Bots & more particularly Chatbots are on every lip! Why this buzz? The answer is very easy: AI has become mainstream thanks to vendors such as Microsoft, IBM and others. Chatbots make use of computational linguistics behind the scenes, not a new concept though, since Alan Turing was already working on that in the nineteen-fifties! So, what has changed in the meantime, why do we sunddenly reach a new paradigm? Resources & Data are the answers as today, the amount of available information & hardware capabilities have increased dramatically. Continue reading

Posted in Azure, Azure Cognitive Services | Tagged , , , | Leave a comment

Implicit Grant flow and group membership within ID_TOKEN

Hi,

I recently realized thanks to a colleague @MMeuree, that the ID_TOKEN that’s supposed to contain the group membership as shown below:

idtoken

does not list more than 4 groups (here I grabbed the token using another flow). So, if the user belongs to more than 4 groups, you’re going to see hasgroups: true as part of the token instead of the actual groups. This behavior is by design no matter what you specified in the App manifest with regards to the groupMembershipClaims attribute. So, the alternative is simply to query the Graph API.

Happy Coding!

Posted in Azure, Azure Active Directory | Tagged , , | Leave a comment

Creative way of exposing on-premises APIs through Azure API Management

Hi,

In this blog post, I’ going to explain what I consider a creative way of exposing on-premises APIs. Let’s envision the following scenario:

You have an on-premises API that is secured using Windows Authentication and for which you need to know the identity of the caller. This API is already consumed by various on-premises consumers and you want to make it also available to online consumers but you want to benefit from throttling and caching capabilities of Azure API Management.

A traditional way of doing this could be by hosting your on-premises API into a DMZ and plugging the APIMGMT to that DMZ endpoint. Another way is using VNETs and VPN techniques to control and establish connectivity. That said, you’d control the connectivity but you should still be able to control identity as per our scenario, this is a pre-requisite for your backend API to know the identity of the user consuming it (via an App).

Continue reading

Posted in Azure, Azure Active Directory Proxy | Tagged , , | Leave a comment

Still hesitating which sessions to attend at #techorama? You might want to go to API Management in Azure

Hi,

This year, at Techorama, I’m going to speak about API Management in Azure. Although this topic is not new, I realized it’s pretty unknown by peers I talk to. Here are the agendas of my sessions, as I cover this topic in two different sessions:

Part I

  • What is APIMGMT?
  • Let’s have a look at the management portals
  • How to publish an API
  • How to deal with policies
  • Monetizing APIs & Integrate with other systems

Part II

  • Using network-related techniques to prevent unexpected access to backend APIs
  • Controlling who’s accessing backend APIs (gateway, other?)
  • Enabling different consumption routes
  • Exposing on-premises APIs from Azure AD Proxy published on-premises applications

Happy Coding!

Posted in Azure | Tagged | Leave a comment

Think twice before enabling Bing Spell Check at LUIS level

Hi,

Enabling Bing Spell Check, one of the Azure Cognitive Services at LUIS level is a piece of cake, indeed, this involves the following steps:

  • Getting a key
  • Registering the key in LUIS
  • Associating that key to your LUIS application

Once done, you also need to change a few things in code:

[LuisModel("appid", "appkey",LuisApiVersion.V2,null,true,true)]

Continue reading

Posted in Azure Cognitive Services, NLP | Tagged , , | Leave a comment

Microsoft bot framework tip: mind the mentions

Hi,

As you know, the Microsoft bot framework is mutli-channel, therefore, when users start talking to a bot from Teams, they may mention it in order to interact with your bot.

So far so good but you should mind the mention as it it sent to your bot on the form:

<at>bot name</at>

meaning that if you leave it “as is” and if you’re using LUIS behind the scenes, your bot will suddenly misunderstand a lot of things. Therefore, make sure to remove the mentions as your first coding action:

activity.Text = Regex.Replace(activity.Text, "<at>.*</at>", "", RegexOptions.IgnoreCase).Trim();

Happy coding!

Posted in Azure | Tagged | Leave a comment

Dialogue tip with the Microsoft botframework

Hi,

Admittedly, dealing with dialogues within the bot framework isn’t an easy task. We often have to struggle to make that damn thing do what we want it to do. I recently had to include a potentially rich answer during one of my dialogues.  In short, the answer to a given question could contain a video but could as well be a basic text.

Moreover, this is only one step of the whole dialogue.  As I had to fight a little bit to get it work, I thought it might be worthwhile to make a short blog post about it.  So here is the code:

[Serializable]
public class VideoAnswer : IDialog<IMessageActivity>
{
    string _link = string.Empty;
    string _text = string.Empty;
    public VideoAnswer(string text,string link)
    {
        _link = link;
        _text = text;
    }
    public async Task StartAsync(IDialogContext context)
    {

        var reply = context.MakeMessage();
        reply.Text = _text;
        if (!string.IsNullOrEmpty(_link))
        {
            VideoCard card = new VideoCard();
            card.Text = "We found a video that should help you";
            List<MediaUrl> medias = new List<MediaUrl>();
            medias.Add(new MediaUrl
            {
                Url = _link
            });
            card.Media = medias;
            reply.Attachments.Add(card.ToAttachment());
        }
        await context.PostAsync(reply);
        context.Done(reply);
    }
}

[Serializable]
public class KbDialog : IDialog<object>
{
    string _path = null;
    Guid _source = Guid.Empty;
    public KbDialog(string path,Guid source)
    { 
        _path = path;
        _source = source;
    }
    public async Task StartAsync(IDialogContext context)
    {
        context.Call(Chain.From(() =>
            Chain.Return(SPUtils.GetSharePointAnswerToQuestion(_path, _source)))
            .ContinueWith<SharePointKB, IMessageActivity>(async (ctx, answ) =>
            {
                var a = await answ;
                return new VideoAnswer(
                    a.Answer,
                    a.VideoLink);
            })
            .ContinueWith<IMessageActivity, bool>(async (ctx, act) =>
            {
                return new PromptDialog.PromptConfirm(
                    Config.Cfg.DidItHelpPrompt, Config.Cfg.DidItHelpPromptInvalidAnswer, 100);
            }
            ), OnQAComplete);
    }

    private async Task OnQAComplete(IDialogContext context, IAwaitable<bool> result)
    {
        //do your stuff
        context.Done(this);
    }
}

The idea of the above code is to get some answer from SharePoint when a user asks a question. My KB may contain a video or not. So here in the KbDialog, which is itself part of a root dialog, I start getting the answer from SharePoint and I pass it to the next step on the form of a SharePointKb object. The next step’s output is an IMessageActivity which is implemented inside of the VideoAnswer class, itself implementing the IDialog interface. Within that separate dialogue, I reply either with text-only, either with text & video but always on the form of a IMessageActivity.

Happy Bot Coding!

Posted in Azure | Tagged | Leave a comment