microsoft / BotFramework-Emulator

A desktop application that allows users to locally test and debug chat bots built with the Bot Framework SDK.
https://aka.ms/botemulator
MIT License
1.81k stars 752 forks source link

Ability to add values to the channel data #2365

Closed sunamc1 closed 2 years ago

sunamc1 commented 2 years ago

Is your feature request related to a problem? Please describe. For local testing at Nationwide, we need the ability to send security values on the channelData that are populated in the higher environments

Describe the solution you'd like The ability to add to the bot configuration or to the settings, values that should be consistently populated in the channelData

Describe alternatives you've considered We can try doing overwrites in the code, but that would require making testing specific hacks in our code.

Additional context We are potentially willing to develop this ourselves and contribute it back to the main project.

[enhancement]

stevkan commented 2 years ago

@sunamc1, Emulator has the option to send a custom activity where you can define properties to be included in channelData. You can find this in the menu under Conversation => Custom activity (new).

image

image

Outside of that, there isn't any way to attach arbitrary channel data to each outgoing message. You are, of course, welcome to submit any PRs in support of this.

As an alternative, you could set up instance of Web Chat that would allow you to send added values in channelData, consistently. Under the hood, both Emulator and Web Chat rely on Direct Line for connecting, so both use cases should produce similar results. Check out this sample, 04.api/b.piggyback-on-outgoing-activities, if you are interested.

For clarity, Web Chat doesn't have to be published for it to work. In my development environment, I run a local 'token' server and web server. From the served page hosting Web Chat, I call an API on the token server which returns the token to be consumed by Web Chat for creating the DirectLine object. If your bot is also running locally, then you can use ngrok, or another tunneling service, to connect your bot to your Azure bot registration. In this way, both your bot and Web Chat are connected to the Direct Line channel connector.

sunamc1 commented 2 years ago

Thanks that's very helpful!