Monday, 16 July 2018

End to End Developer example video of basic Cortana skill






For those wanting a visual walk through of the process to create a Cortana skill with botframework!

Uses node.js.

Friday, 13 July 2018

Get your Azure QnA Bot to Speak with Cortana

Building a QnA bot and hooking it up to Cortana is simple in node.js under BotFramework V3.

If you have a FAQ that is in Q: A: format you can import it via the Azure QnA Maker tools and auto-create a "knowledge base".  No coding required. You can do this here https://www.qnamaker.ai.

The next step is creating your bot. Microsoft has standardized on their botframework to do this. https://dev.botframework.com is your gateway.

If you are like me and like the simplicity of node.js then pick the QnA template.

Go back to qnamaker and view the code to extract the QnA keys and host.
Then go back to the Azure portal and update your bot for the Application Settings blade sections shown here.

The test web app will now be successfully linked to your QnA bot! But don't forget the last step...

Go to your Channels blade and set up Cortana. Then, go to the build blade and open the online editor. In the app.js code, you will see that the template uses the standard QnA dialog builder - that does not say the resulting answers back with the Cortana speech channel. Add an override like this.


(See GitHub QnAMaker patch for a V4 node example.)

There you have it. Now "Hey Cortana, ask Bernie Question Bot Test what is a dwarf planet?"




For C#, it is slightly more complicated. You need to subclass the the BasicQnAMakerDialog with something that sends a message with speak attached. This is done as an inner class of RootDialog (from the V3 C# template that comes with Azure Web App Bots.

    // Dialog for QnAMaker GA service
    [Serializable]
    public class BasicQnAMakerDialog : QnAMakerDialog
    {
        // Go to https://qnamaker.ai and feed data, train & publish your QnA Knowledgebase.
        // Parameters to QnAMakerService are:
        // Required: qnaAuthKey, knowledgebaseId, endpointHostName
        // Optional: defaultMessage, scoreThreshold[Range 0.0 – 1.0]
        public BasicQnAMakerDialog() : base(new QnAMakerService(new QnAMakerAttribute(RootDialog.qnaAuthKey, RootDialog.qnaKBId, "No good match in FAQ.", 0.5, 1, RootDialog.endpointHostName)))
        { }

        // Override to also include the knowledgebase question with the answer on confident matches
        protected override async Task RespondFromQnAMakerResultAsync(IDialogContext context, IMessageActivity message, QnAMakerResults results)
        {
            if (results.Answers.Count > 0)
            {
                IMessageActivity response = context.MakeMessage();
                response.Text = "Here is the match from FAQ:  \r\n  Q: " + results.Answers[0].Questions[0] + "  \r\n A: " + results.Answers[0].Answer;
                response.Speak = response.Text;
                response.InputHint = "acceptingInput";
                await context.PostAsync(response);
            }
        }
    }

(See GitHub QnAMaker patch for a V4 C# example.)

Getting the most out of your free Azure subscription for development.

I discovered why my Azure free trial was eating cash. It seems that the free trial defaults to reasonable paid service tiers, and not the free development tiers. So when you set up your Microsoft account (MSA) for development purposes, make sure you double and tripple check that the plan you pick starts with an F (for free) and not an S.

When you use bot builder or QnA builder, you might need to go back after you create a project from template and change the "App Service Plan" to something free. If you see your $ decreasing and you're not doing anything - you've configured something incorrectly.


Thursday, 12 July 2018

Building Bots in Azure

I am starting to build Cortana bots. So far its been interesting.

I had trouble building the Azure function bots from template. The node.js example for the simple "echo" bot... First crack, the Azure "Test in Web Chat" didn't work. Errors implied there was a permission issue.

I tried again, and had a deployment error on the bot function template.

I tried again, and on the third try it deployed. To my knowledge, I did nothing differently.

The advantage of a function bot over a web app bot is supposedly pay per invocation (that should be cheaper, right)? The issue with the example code for node.js on the function bot is that every potential used library is embedded in the index.js code where the two line "echo" functionality is embedded in the middle!

WHY?  Why? Well, javascript as a language doesn't have a '#include' statement. Client side, you do the includes on the document for your browser to take care of.

In node, we have requires... that allows us to load modules. But why is this not used in the function bot example? I figure its a work around. But the down side is this: every time I edit the function in the portal for this example, I am touching a 200K line file! 




Tuesday, 21 March 2017

Pi Zero W

When I installed the SD the Pi Zero W came with from CanaKit, I had a heck of a time getting it working. First, the micro USB hub I had from Amazon basics didn't work.
Then I had to manually load up the wifi config.
I installed libSDL, advmame (thanks Silverman) and fceux and ... performance was crappy.
But I couldn't see anyone else saying Asteroids was broken out the box.
So I tried to install my Pi2 SD...
I learned that older versions of raspbian don't work with the Zero. Not even if you
  • sudo apt-get update
  • sudo apt-get install rpi-update
  • sudo apt-get dist-upgrade
  • sudo rpi-update
    Its because PiZeroW runs best with the latest raspbian build, Jessie. It doesn't like the old build, Wheezy as the wifi is flakey.
    So after a couple flips of build, it looks like my original video settings we mangled on the SD card that shipped with the Pi Zero W. My latest attempt work - and Pacman is playable with latest advMame - but asteroid is not. That said, Super Mario works like a charm...
    Now I need to discover how to tune the Pi Zero.
    And my Orange Pi arrived...
  • Saturday, 25 February 2017

    PiPlay struggles.

    The PiPlay interface randomly hangs. Fortunately the web interface allows a reboot.

    Setting up a joystick is not intuitive. You need to install the jstest and set the codes in a variety of config files. As far as I can tell, the controller config python script does not work.

    For SNES, go to the emulators directory and find the snes9x.cfg file. Update the mappings in there (after you've installed and run jstest to figure out what the buttons are.)

    For NES, you need to jump through a few hoops. First, "startx" from CLI. Then, find the fceux directory (in the pimame emulators directory). Start a terminal in X. Run the fceux --inputcfg gamepad1 command and set up the buttons.

    For advmame, find the default.cfg and add your joystick settings. You can get a hint what they should be via tab in the emulator.

    I finally got sound working on astroblaster and starcastle. The trick is to find the sound samples with the same name as the roms and install it in the sample directory. You can find this in the .advance directory (hidden) in the ~pi directory (that is home). I haven't tried donkey kong yet, but if that works, I'm in heaven.

    Sunday, 19 February 2017

    PiPlay on Raspberry Pi 2




    Yes, I finally got around to it. I installed MAME on my Pi 2. After trying to install it on my existing SD card, I figured I'd just use a pre-existing image. win32diskimager is the tool to backup your old images and image and make new ones. Pick either of these two images.


    Add DHCP to the wireless network adapter. Go to raspi-config (tools) and resize the partition to use all 8G. Reboot the thing and install the latest MAME via its home screen. Reboot again. HTTP into the Pi and use the PiPlay upload for ROMs. Have tons of fun.
    br> Here is my gear.