All posts by Ezequiel Jadib

Using Facebook’s QuickReplies with PromptDialogs

In my last post I showed how easy it is to send Facebook’s quick replies using Microsoft Bot Framework. Using what we’ve learned; I’m now going to show you how you can use quick replies when using a PromptDialog.


Some of the PromptDialogs coming out of the box with the BotBuilder library (like the PromptChoice or PromptConfirm) expects a set of options (like the options to choose from) to be presented to the user. By default, these dialogs use a PromptStyler that based on the PromptStyle selected when creating the dialog; it will render the options in different ways: cards with buttons, all the options inline or one option per line to mention some of them.

The good news is that you can create your own PromptStyler and so, change the way the options are being rendered.


At this point, you might already have spotted what I will be doing as part of this post Smile. The whole idea is to create a custom PromptStyler that will take the provided options and render them as quick replies.


The code
The full sample is in GitHub. To run the sample, publish your bot, for example to Azure or use Ngrok to interact with your local bot in the cloud.

The code is extremely simple and is taking advantage of the models I put together in the previous post.

public class FacebookQuickRepliesPromptStyler : PromptStyler
public override void Apply<T>(ref IMessageActivity message, string prompt, IList<T> options)
if (message.ChannelId.Equals("facebook", StringComparison.InvariantCultureIgnoreCase) && this.PromptStyle == PromptStyle.Auto && options != null && options.Any())
var channelData = new FacebookChannelData();

var quickReplies = new List<FacebookQuickReply>();

foreach (var option in options)
var quickReply = option as FacebookQuickReply;

if (quickReply == null)
quickReply = new FacebookTextQuickReply(option.ToString(), option.ToString());


channelData.QuickReplies = quickReplies.ToArray();

message.Text = prompt;
message.ChannelData = channelData;
base.Apply<T>(ref message, prompt, options);


Using it in your dialogs is a no-brainer. Just provide an instance of the new PromptStyler when defining the prompt options and that’s it.

var promptOptions = new PromptOptions<string>(
"Please select your age range:",
options: new[] { "20-35", "36-46", "47-57", "58-65", "65+" },
promptStyler: new FacebookQuickRepliesPromptStyler());

PromptDialog.Choice(context, this.ResumeAfterSelection, promptOptions);


One caveat that I’m not addressing in this post is how to access the payload of the quick replies from the PromptDialog. In order to access to the payload, you will likely have to extend the PromptDialog (PromptConfirm is sealed but you can inherit from PromptChoice), override the MessageReceivedAsync and/or the TryParse and include the logic related to extracting the payload. Please refer to my previous post for the logic on how to extract the payload.


The outcome




Sending Facebook’s Quick replies using Microsoft Bot Framework

Facebook’s quick replies are a great way to present buttons to the users. Per Facebook’s Quick Replies documentation:

Quick Replies provide a new way to present buttons to the user. Quick Replies appear prominently above the composer, with the keyboard less prominent. When a quick reply is tapped, the message is sent in the conversation with developer-defined metadata in the callback. Also, the buttons are dismissed preventing the issue where users could tap on buttons attached to old messages in a conversation.

Taking advantage of this feature when using Microsoft Bot Framework is really simple, even knowing this functionality is very specific to Facebook.

If you want to use special features or concepts for a channel, the Bot Framework provides a way to send native metadata to that channel giving you much deeper control over how your bot interacts on a channel. The way Bot Framework enables this is through the ChannelData property in the C# SDK and the sourceEvent property in Node.js.

Not every capability provided by a channel must go through the ChannelData property; that will basically depend on whether the functionality can be consistent across channels. When that’s the case, it’s very likely the functionality will be addressed in the core API, like with Rich card attachments.


The code

The full sample is in GitHub. To run the sample, publish your bot, for example to Azure or use Ngrok to interact with your local bot in the cloud.

The quick replies schema is pretty straightforward. Below is the portion of the code that creates some text only quick replies and assigns them to the activity’s ChannelData.

if (reply.ChannelId.Equals("facebook", StringComparison.InvariantCultureIgnoreCase))
var channelData = JObject.FromObject(new
quick_replies = new dynamic[]
content_type = "text",
title = "Blue",
image_url = ""
content_type = "text",
title = "Green",
image_url = ""
content_type = "text",
title = "Red",

reply.ChannelData = channelData;

Note that in the code I’m checking for the channel so quick replies are only sent in outgoing messages to a Facebook channel.

: If you are planning to use quick replies in many places or in many bots and you don’t want to remember the required schema; I would recommend creating some helper classes to ease the work. I included those as part of the sample, and now the code looks like:

var channelData = new FacebookChannelData
QuickReplies = new[]
new FacebookTextQuickReply("Blue", "DEFINED_PAYLOAD_FOR_PICKING_BLUE", ""),
new FacebookTextQuickReply("Green", "DEFINED_PAYLOAD_FOR_PICKING_GREEN", ""),
new FacebookTextQuickReply("Red", "DEFINED_PAYLOAD_FOR_PICKING_RED")

When a Quick Reply is tapped, a text message will be sent to your webhook Message Received Callback. The text of the message will correspond to the title of the Quick Reply. The message object will also contain the payload custom data defined on the Quick Reply.

Accessing the payload information only requires using the ChannelData of the message received after the user tapped the Quick Reply button. Optionally, you can create a typed model of the response and deserialize the channel data.

private async Task OnColorPicked(IDialogContext context, IAwaitable<IMessageActivity> result)
var colorMessage = await result;

var message = $"Color picked: {colorMessage.Text}.";

if (colorMessage.ChannelId.Equals("facebook", StringComparison.InvariantCultureIgnoreCase))
var quickReplyResponse = colorMessage.ChannelData.message.quick_reply;

if (quickReplyResponse != null)
message += $" The payload for the quick reply clicked is: {quickReplyResponse.payload}";
message += " It seems you didn't click on a quick reply and you just typed the color.";

await context.PostAsync(message);



The outcome

As soon as you send a message to the Bot, it will respond with a question and the three quick replies. Intentionally, I’m showing quick replies with and without images.


Once you tap on the quick reply button, the Bot will respond with the selected color and also it will show the defined payload for the quick reply button.


Quick replies are just hints, you can still type something different, in which case the sample will detect that you didn’t tap on a quick reply button and it won’t look for the defined payload.



As you can see, quick replies are powerful and really easy to use right from your Bot Framework based bot. If one of the channels you are supporting within your bot is Facebook, I would strongly recommend using them. To learn more about Facebook features with Bot Framework, please read here.

Enjoy Windows Azure Media Services in the Comfort of your own Console

A few days ago Damian Schenkelman did a brown bag about scriptcs. Right after he explained Script Packs I asked if there was something already in place for Azure Media Services.

“Not yet”, he said. Thus I decided to start authoring one given two main motivations:

    • To learn more about scriptcs.
    • My past experiences in high profile events

There isn’t much to say regarding the first bullet (learning new stuff is part of my DNA); however I will expand on the second one.

During the last few years I have had the opportunity to be part of the streaming operations war room in high profile events (such as the London 2012 Olympics) where things happen really fast and troubleshooting can be stressful. Sometimes you need to quickly check the state of an asset or a job status and there is certainly no time to launch Visual Studio, start building a console application, etc. to look over everything.

At that time, we had a lot of tooling helping on a daily basis and a few handy tools to check things over. However…wouldn’t it have been great if you could have just started your console and started coding away to interact with Windows Azure Media Services?

Now it’s possible Smile


Go ahead and take a look at the docs of this script pack to get started. I would like to thanks Damian Schenkelman for his contributions to the script pack

If you want to learn more about scriptcs, be sure to check out the project wiki and read the blog posts created by the community.


Happy scripting.


Windows Azure Media Services SDK 2.0 for .NET (Preview) – Release Candidate

The release candidate of Windows Azure Media Services SDK for .NET was published on NuGet a few days ago. As explained in this post, the older preview SDK version 1.0 is now considered deprecated and you should uninstall it a recompile your app using the 2.0 release.


This new release includes new functionality and some breaking changes that you should be aware in order to recompile you app against this new SDK. The Media Services Documentation on MSDN will be fully updated by 11/27, but you don’t have to wait until then to migrate your app.

Nick Drouin published some code snippets here, which will help you get started with the new SDK. (BTW, I strongly recommend reading Nick’s blog for getting sample code and how-to articles around using various features of Media Services)

Windows Media Services SDK 2.0 Release Notes

Media Services General Issues











Several   common HTTP headers are not provided in the REST API.

If you   develop Media Services applications using the REST API, you find that some   common HTTP header fields (including CLIENT-REQUEST-ID, REQUEST-ID, and   RETURN-CLIENT-REQUEST-ID) are not supported. The headers will be added in a   future update.

Media Services SDK for .NET Issues











Media   Services objects in the SDK cannot be serialized and as a result do not work   with Windows Azure Caching.

If you   try to serialize the SDK AssetCollection   object to add it to Azure Caching, an exception is thrown.


Changes since June 2012 release

SDK Changes

The following changes require any code written against the June 2012 Preview release to be modified:


IAsset.Create(assetName) is the ONLY asset creation function.  IAsset.Create no longer uploads files as part of the method call.

The IAsset.Publish method and the AssetState.Publish enumeration value have been removed from the Services SDK.  Any code that relies on this value must be re-written.


This class has been removed and replaced by IAssetFile.  See below.


Replaces FileInfo and has a different behavior. To use it, instantiate the IAssetFiles object, followed by a file upload either using the Media Services SDK or the Windows Azure Storage SDK. The following IAssetFile.Upload overloads can be used:

    • IAssetFile.Upload(filePath).  Synchronous method.  Blocks the thread and is recommended only when uploading a single file.
    •  IAssetFile.UploadAsync(filePath, blobTransferClient, locator, cancellationToken).  Asynchronous method.  This is the preferred upload mechanism. Known bug: using the cancellationToken will indeed cancel the upload; however, the cancellation state of the tasks can be any of a number of states. You must properly catch and handle exceptions. 


The Origin-specific and Windows Azure CDN-specific versions have been removed. The SAS-specific context.Locators.CreateSasLocator(asset, accessPolicy) will be marked deprecated, or removed by GA. See the Locators section under New Functionality for updated behavior.

New Functionality

The following functionality is new in the November 2012 release.

Deleting entities

IAsset, IAssetFile, ILocator, IAccessPolicy, IContentKey objects are now deleted at the object level, i.e. IObject.Delete(), instead of requiring a delete in the Collection, that is cloudMediaContext.ObjCollection.Delete(objInstance).


Locators must now be created using the CreateLocator method and use the LocatorType.SAS or LocatorType.OnDemandOrigin enum values as an argument for the specific type of locator you want to create.  

New properties were added to Locators to make it easier to obtain usable URIs for your content. This redesign of Locators was meant to provide more flexibility for future third-party extensibility and increase ease-of-use for media client applications.

Asynchronous Method Support

Asynchronous support has been added to all methods. 

Enjoy the new SDK!

Windows Azure Media Services preview launched!

Media Services ArchitectureThe wait is over! Back in April, Microsoft announced Windows Azure Media Services (see here and here) and yesterday the preview became available as part of the Spring release announcements.

We had the opportunity to try the bits as part of the TAP program and I can tell you that this is worth trying. The usage of the SDK API is really friendly and with the getting started and how to documents (see below) you will be able to get started in a heartbeat.

Supported Features

This preview release supports:


  • Use the Windows Azure Media Encoder and work with a range of standard codecs and formats, including industry-leading IIS Smooth Streaming, MP4, and conversion to Apple HTTP Live Streaming.
  • Convert entire libraries or individual files with total control over input and output.
  • Supported video and audio codecs:
    • H.264 High, Main and Baseline Profiles
    • AAC-LC
    • HE-AAC
    • VC-1 (Windows Media Video 9) Simple, Main and Advanced Profiles
    • Windows Media Audio Standard
    • Windows Media Audio Professional
  • Supported format conversions:
    • ISO MP4 (.mp4) to Smooth Streaming File Format (PIFF 1.3) (.ismv; .isma)
    • Smooth Streaming File Format (PIFF) to Apple HTTP Live Streaming (.msu8, .ts)

Content Protection

  • Encrypt live or on-demand video and audio with standard MPEG Common Encryption or Microsoft PlayReady, the industry’s most accepted DRM for premium content.

On-Demand Streaming

  • Streaming Origin support for Smooth Streaming and Apple HTTP Live Streaming
  • Seamlessly deliver content via Windows Azure CDN or a third-party CDN.
    • Add a scalable origin server with or without a CDN.
    • Scale to millions of users by adding a Windows Azure CDN or a third-party CDN.


Here is a list of resources that will help you get started with Windows Azure Media Services:

Stay tuned! Many exciting features are planned for future releases.


Microsoft Media Platform Video Editor (former RCE) 2.0 – Silverlight 5 Refresh released

Heads up! A refresh of the MMP Video Editor 2.0 was released today. This release doesn’t contain any new feature and is just a refresh to use the latest Silverlight 5.

The 2.0 release was built using the Silverlight 5 Beta bits, which already expired so some users were getting the message “This application was created for an expired beta release of Silverlight. Please contract the owner of this application and have them upgrade their application using an official release of Silverlight” when trying to use the application.

Happy editing,


Quick Tip: Smooth Streaming suddenly stops working

A few days ago I noticed that smooth streaming had stopped working in my development machine. Every time I tried to GET a manifest, I received the infamous HTTP Error 500.0 – Internal Server Error screen.


My first try to fix this was, obviously, reinstalling the IIS Media Services package. Sadly, that didn’t help.

After that, I started to think that the problem could be in the handler mapping, so I took a look at them in IIS and I found that the SmoothHandler in the Default Web Site has an Unspecified path type instead of the usual File path type.


Changing the path type back to File, solved the issue.


Alternatively, if you don’t have local configurations, you can revert the Handler Mappings to its parent.



Hope this helps,


MMP Video Editor Transform Manager Task updated to IIS Transform Manager 1.0 Beta

A few months ago, Microsoft published the Beta version of the IIS Transform Manager. This new release contains an incredible set of new features, explained here by Chris Knowlton.

Back in the Alpha days, I wrote an IIS Transform Manager Task that takes an Microsoft Media Platform Video Editor (formerly Rough Cut Editor) Project XML file (which includes the EDL) as input, and outputs a new encoded video that represents the MMP Video Editor edits.

The Beta version introduced a few breaking changes (mainly due to interfaces renaming) so I decided to publish an updated version of the task, so you can use it without having to perform the changes.

The updated task can be downloaded from here.


Happy Transforming!

Silverlight Rough Cut Editor SP1 Released

Microsoft just released the SP1 version of the Silverlight Rough Cut Editor.

This service pack addresses some of the most requested requirements by the community.

In this post you will find detailed information about what this release contains.


Service Pack Content

In this service pack you will find:

  • The RCE migrated to Visual Studio 2010, Silverlight 4 and IIS Smooth Streaming Client 1.5.
  • Issues fixed that improve CPU performance.
  • Bug fixing.
  • An enhanced setup experience with automation scripts for Windows 7, Windows 2008 and Windows 2008 R2.
  • Composite Stream Manifest generation integrated with the RCE.
  • An updated version of the Composite Stream Manifest generator that supports  manifest compression and the new IIS Media Services 4.0 manifest format (duration based).
  • A new Assets Data Provider that retrieves the assets from a plain XML.
  • A source code refactoring that takes advantage of the Smooth Streaming Plugin provided by the Silverlight Media Framework.

New Setup Experience

Two packages were released as part of the SP1. One contains the source code and the other one contains the binaries ready to be hosted.

In both packages you will find a start here document that will help you to install the Rough Cut Editor. They also contain a new set of scripts to automate the deployment in 3 platforms: Windows 7, Windows 2008 and Windows 2008 R2.

Note: If you are trying to run the RCE in another platform, please refer to the topic in the CHM documentation that explains how to do a manual deployment of the solution.

The scripts will first detect if the pre-requisites required to run the the RCE are installed and then, will perform all the operations required to leave the RCE up and running in your environment.

image image

After installing the package, you will find a shortcut in the desktop to run the solution.



Composite Stream Manifest Generator Additions

The IIS Media Services 4.0 has a new manifest format (duration based instead of time based) and also adds support for a new repeat tag “r” to obtain more compression in the manifest.

The new format is compatible with the previous version of the Smooth Streaming Media Element (SSME) , but the manifest compression feature it is only compatible with SSME >= v1.5.

For more information about these changes, please read this blog post from Giuseppe Guerrasio.

The Composite Stream Manifest generator now outputs CSMs following the new proposed format and also has the ability to compress the output manifest.

In the Test Page of the CSM generator, you will find a new checkbox that will allow you to test the manifest compression.


You can read more about the CSM generator in this blog post.


Composite Manifest Generation integrated with the RCE.

How many times you were using the RCE and wanted to quickly generate a CSM to check how your edits look like? Before SP1, you were required to export the RCE project, copy its content and paste it on the generator test page, generate the manifest, copy the generation output and host the CSM. Looong process. You can imagine how quickly that turns into a repetitive task.

The RCE SP1 has the CSM generator integrated as part of the Output module. Now you select a CSM output, click Export and the CMS will be generated and hosted for you. The generated CSM ends up in the RCE.Web/encode/CSM directory.



I hope you find this new release useful. If you have comments, questions, suggestions or any issue, please visit the Rough Cut Editor community site.

Happy editing!

Rough Cut Editor (RCE) and IIS Transform Manager: Best Friends

A month ago, Microsoft published the alpha version of the IIS Transform Manager. The Transform Manager provides simple integrated video encoding and batch conversion of video files to the IIS Smooth Streaming format.  It does this quite nicely, as it provides an extensible platform for scheduling and running multiple tasks in sequence on an IIS server using a local task scheduler. It enables “watch folder” job submission, queuing, management, integrated media transcoding/transmuxing, and batch-encryption of on-demand audio and video files. You can get more information from here, here and here.

My friend John Deutscher is leading these efforts. John has a lot of experience with media management software and a passion to make developers lives’ easier. He was also one of the masterminds behind the Rough Cut Editor (RCE), a lightweight, Web-based Silverlight video editing tool. As a client tool, it submits edit decision lists, but does not include the logic for transcoding. But it’s highly extensible, and from time-to-time, we’ve been asked about extending the tool to add an encoding workflow process.

The real question here is whether the RCE should take care of that. Instead, Why not take advantage of the tools available out there and use them to manage the complexity of the encoding process?

This post is result of exploring the feasibility of using the IIS Transform Manager to take an RCE Project XML file (which includes the EDL) as input, and creating the necessary task to output a new encoded video that represents the RCE edits?

So with that goal in mind, I started to build a proof of concept of the scenario, depicted in the following diagram:


PoC Diagram – (icons from

The Ingredients

The Recipe

OK. Let’s assume we have all the ingredients in place and that we are ready to start.

The first thing to do is to create the Transform Manager Task. This task will parse the RCE Project XML, extract the edits metadata and use that information with the Expression Encoder 4 API to perform the encoding.

I will not copy all the code for the Task in the post (you can download that from here. Make sure to include into the libs folder the EE4 and IIS Transform Manager assemblies in order to build the project), but instead let me highlight a few things:

  1. To create a custom Task for the IIS Transform Manager you must implement the ITransformTask interface (Microsoft.Web.Media.TransformManager.Sdk.dll)
  2. Once you have created the task, you must create a task definition xml file (the task definition schema can be found here).
    The following is the Task Definition for the RCE Project task:

    <taskDefinition xmlns=> <name>RCE Project Task</name> <id>7F8A89DA-1DF9-409A-9869-A5CDCA017998</id> <properties namespace=> <property name=presetvalue=“” /> </properties> <description xml:lang=en>Invokes Expression Encoder 4 to produce a video based on the edits metadata defined on an RCE Project File</description> <inputDirectory></inputDirectory> <outputDirectory>RCEProjectTaskOutput</outputDirectory> <taskCode> <type architecture=x86>RCE.TransformManager.Tasks.RCEProjectTask, RCE.TransformManager.Tasks, Version=, Culture=neutral, PublicKeyToken=null</type> </taskCode> </taskDefinition>

    As you can see, it defines a property called preset, which is intended to be used to provide the Expression Encoder 4 preset.

    – The input directory points to the directory where the source videos are located (which is the same directory used on the RCE File System Data Provider configuration)

    – The output directory will be later used by an XCopy task defined on the Job Template that will copy the resulting files back to the source videos directory (making the resulting video available to the RCE)

  3. Register the task with the IIS Transform Manager. A great tutorial on how to do custom task registration can be found here, but it basically involves two steps:- Copy the custom task assembly to C:Program FilesIISTransform Manager (on a x86 computer) or to to C:Program Files (x86)IISTransform Manager (on a x64 computer)

    – Copy the custom task definition XML file to the %ProgramData%MicrosoftIISTransform ManagerConfigurationTask Definitions directory

Once you have your Transform Manager task ready and configured, launch the Internet Information Services and configure the IIS Transform Manager.

First, stop and start the IIS Transform Manager service so it can detect the new task, then follow these steps to create a job template.

  1. Create a New Job Template (Transform Manager > Job Templates > New) and fill the Name field.image
  2. Click Add to launch the Add Task dialog.image
  3. Select the RCE Project Task and the XCopy Task and click OK.
  4. Make sure that the task definitions list shows the RCE Project task on top of the XCopy task (use the Move Up / Move Down buttons to adjust it)image
  5. Select the RCE Project Task and click Edit.
  6. Fill the input directory field and the preset property. Click OK to save.imageNote: I’m using one of the predefined presets of EE4 (VC1-ScreenEncoding VBR for Silverlight), but you can use any you prefer.
  7. Select the XCopy task and click Edit.
  8. Fill the fields as described below. Click OK to save.
    • Input Directory: RCEProjectTaskOutput
    • Arguments: RCEProjectTaskOutput* “d:mediademovideos” /E /Y /INote: (replace d:mediademovideos with the input directory you defined on the RCE Project Task)image
  9. Click OK to save the job template.

Now it is time to add the Watch Folder. For the sake of simplicity, in the PoC, I will use the folder where the RCE exports the project output. This folder is located at


Note: For this PoC, I’m running all the components (RCE, IIS Transform Manager, Expression Encoder 4) in the same computer, which is unlikely for a production environment, but makes it easy to develop on a single machine.
  1. Create a new watch folder (Transform Manager > Watch Folders > New)
  2. Fill the watch folder settings:
    • Name. The name of the folder
    • Physical Path. The watch folder path (%RCEDirectory%/RCE.WebencodeQueue)
    • File Filter. Use *.jobreq here, which is the extension the RCE Export operation output.
    • Job Template. Select the RCE Job Template image
  3. Click OK to save the watch folder.
  4. Finally, select the watch folder and click Enable and then click Start. This will leave the watch folder ready to use.



Great!. Everything is cooked. Let’s see how it tastes.

  1. Launch the RCE and perform a couple of edits. I’ve four videos on my library and I created an edit of around 1 minutes and 56 seconds using two of those videos.image
  2. Select the Output Tab, and click Export to export the RCE project.image
  3. Open the IIS and go to the Job Monitor option of the IIS Transform Manager. You will see that your job is running!!image
  4. Once the encoding is completed, the second task of the job is going to be executed, copying the new file on the folder you configured.
  5. Refresh the RCE (press F5), and you’ll see a new video on the library, with the exact same duration of the edit you created.


The End 🙂

We just proved that the RCE and the IIS Transform Manager can easily work together. The IIS Transform Manager’s extensibility allowed us to create a simple task to integrate the RCE export process with it and to output a new encoded video that represents the RCE edits. And this is just the beginning…

Hope this helps,

Happy Transforming!