0

I understand how to do this in code outside of composer, but is there a way to be able to use this within composer?

There's this: How to get message id of sent message Bot Framework (Teams channel)? but it's not from composer.

Martín La Rosa
  • 790
  • 4
  • 17

1 Answers1

0

It'd have to be in a custom action (as you mention) and then returning resource Id in the result property, so you can use it elsewhere. The BeginDialogAsync method of the custom action would something like this:

public override async Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken))
{
    var activity = Activity.CreateMessageActivity();

    //...

    var resource = await dc.Context.SendActivityAsync(activity);

    if (this.ResultProperty != null)
    {
        dc.State.SetValue(this.ResultProperty.GetValue(dc.State), result);
    }

    return await dc.EndDialogAsync(result: result, cancellationToken: cancellationToken);
}

UPDATE

Updated the code use the "ResultProperty" property, just as the sample custom action in the custom runtime. This way the custom action would be much more reusable.

Miguel Veloso
  • 1,055
  • 10
  • 16
  • Thanks, that's great. I'm also going to create an issue in git hub to see if they can make the SendResponse Action to do this as well – Martín La Rosa May 17 '21 at 20:32
  • Hey, I guess you meant the `SendActivity` action but that comment poked my curiosity and took a peek at the source code and... guess what... [it IS already there](https://github.com/microsoft/botbuilder-dotnet/blob/ececa515fc05c331d4ceeeca4b2b031fee39958c/libraries/Microsoft.Bot.Builder.Dialogs.Adaptive/Actions/SendActivity.cs#L110), just have to check now how to use it – Miguel Veloso May 18 '21 at 08:31
  • I know it already exists in code, but I want to using it from Bot Framework composer. There's a SendResponse action in it, which internally would call SendActivity. But it doesn't return the value you see in C#. Created this issue and the'll take it into consideration for future release: https://github.com/microsoft/BotFramework-Composer/issues/7850 – Martín La Rosa May 18 '21 at 19:51