Edit this page

Suggested Actions

Adding the SuggestedAction

Conversational UI supports adding suggestions to the user. This can be done by adding SuggestedAction items to the SuggestedActions collection of RadChat.

Example 1: Adding SuggestedAction

        var textMessage = new TextMessage(this.currentAuthor, "Hello", "sent");
        textMessage.InlineViewModel.StatusVisibility = Visibility.Visible;

        this.chat.AddMessage(textMessage);

        this.chat.SuggestedActions.Add(new SuggestedAction("Hi there!"));

Adding the SuggestedAction will be visualized as shown in the figure below.

Figure 1: Adding a SuggestedAction

Setting the TypeIndicator

By default the SuggestedActions will be visible. In case they need to be hidden, the SuggestedActionsVisibility of RadChat can be set to Collapsed.

Handling the SuggestedActionReported event

When the user selects a given suggestion, the SuggestedActionReported is raised. Through it the user input can be modified. Its arguments expose the following members.

  • CloseAfterReport: A boolean property that controls whether the message will be removed after it reports a result.
  • PostResultInline: A boolean property that determines whether the suggestion should be posted as an inline text message or not.
  • Text: The text result.

Example 1: Adding SuggestedAction

 private void Chat_SuggestedActionReported(object sender, SuggestedActionsEventArgs e)
    {
        if (e.Text == "Hi there!")
        {
            e.Text = this.otherAuthor.Name + ", " + e.Text;
            e.CloseAfterReport = false;
            e.PostResultInline = true;
        }
    }

Figure 1: Handling the SuggestedActionReported event

Setting the TypeIndicator

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy