Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FormFlow prompts are not being spoken in Cortana Skills

I am building a Coratana skill by first building a bot, using FormFlow. I detect my intents and entities using LUIS and pass the entities to my FormFlow dialog. If one or more FormFlow fields is not filled in, FormFlow dialog prompts the user to fill in the missing information, but this prompt is not spoken, only shows on the cortana screen. Is there any way for FormFlow to speak the prompts?

In the screenshot shown below, the prompt "Do you need airport shuttle?" was just displayed and not spoken:

enter image description here

My formFlow definition looks like this:

 [Serializable]
public class HotelsQuery
{
    [Prompt("Please enter your {&}")]
    [Optional]
    public string Destination { get; set; }

    [Prompt("Near which Airport")]
    [Optional]
    public string AirportCode { get; set; }

    [Prompt("Do you need airport shuttle?")]
    public string DoYouNeedAirportShutle { get; set; }
}
like image 213
user2202866 Avatar asked Feb 04 '23 07:02

user2202866


1 Answers

I don't think Speak is currently supported in FormFlow.

What you could do, as a workaround is adding an IMessageActivityMapper that basically promote text to speak automatically.

namespace Code
{
    using Microsoft.Bot.Builder.Dialogs;
    using Microsoft.Bot.Builder.Dialogs.Internals;
    using Microsoft.Bot.Connector;

    /// <summary>
    /// Activity mapper that automatically populates activity.speak for speech enabled channels.
    /// </summary>
    public sealed class TextToSpeakActivityMapper : IMessageActivityMapper
    {
        public IMessageActivity Map(IMessageActivity message)
        {
            // only set the speak if it is not set by the developer.
            var channelCapability = new ChannelCapability(Address.FromActivity(message));

            if (channelCapability.SupportsSpeak() && string.IsNullOrEmpty(message.Speak))
            {
                message.Speak = message.Text;
            }

            return message;
        }
    }
}

Then to use it, you need to register it in your Global.asax.cs file as:

 var builder = new ContainerBuilder();

 builder
   .RegisterType<TextToSpeakActivityMapper>()
   .AsImplementedInterfaces()
   .SingleInstance();

 builder.Update(Conversation.Container);
like image 167
Ezequiel Jadib Avatar answered Feb 13 '23 12:02

Ezequiel Jadib