By user2202866


2017-06-09 18:29:33 8 Comments

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; }
}

2 comments

@berhir 2017-07-13 17:40:26

The answer form Ezequiel Jadib helped me to solve what I needed for my use case. I just added a few additional lines to set the InputHint field to ExpectingInput if the text is a question. With this configuration Cortana automatically listens to my answer and I don't have to activate the microphone by myself.

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;

        // set InputHint to ExpectingInput if text is a question
        var isQuestion = message.Text?.EndsWith("?");
        if (isQuestion.GetValueOrDefault())
        {
            message.InputHint = InputHints.ExpectingInput;
        }
    }

    return message;
}

@tatigo 2018-12-10 21:43:51

Had the same problem. The InputHints.ExpectingInput was missing

@Ezequiel Jadib 2017-06-09 19:12:14

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);

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] Chatbot using Cortana does not speak

1 Answered Questions

[SOLVED] First prompt of proactive localised formflow in wrong language in bot framework

  • 2018-12-01 08:56:58
  • Azeem Vasanwala
  • 49 View
  • 1 Score
  • 1 Answer
  • Tags:   c# botframework

1 Answered Questions

Cortana Channel Integration to Bot takes to browser after invocation

1 Answered Questions

2 Answered Questions

2 Answered Questions

[SOLVED] Call LUIS from FormFlow in C#

2 Answered Questions

[SOLVED] Handling Cortana interpretation mistakes

2 Answered Questions

0 Answered Questions

How to not prompt during FormFlow on BotBuilder?

0 Answered Questions

Prompts from LUIS model in multi turn bot

  • 2016-07-06 10:21:14
  • sachinkundu
  • 316 View
  • 1 Score
  • 0 Answer
  • Tags:   botframework luis

Sponsored Content