Emulator MS Bot emulator change user id

Is there a way to change the default user id (which is the "default user") in the bot emulator?

Or maybe he is maintaining something about multiple conversations at the same time?

I want to emulate two different users at the same time (because I have multiple user types in my project.

When I try to create a new conversation like this

....
var connector = new ConnectorClient(new Uri(context.Activity.ServiceUrl));
var userAccount = new ChannelAccount("//here we need to provide user id which is always default-user", "Provider");
var botAccount = context.Activity.Recipient;

var conversation = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);
var message = context.MakeMessage();
message.Recipient = userAccount;
message.From = botAccount;
message.Conversation = new ConversationAccount(false, conversation.Id);
await connector.Conversations.SendToConversationAsync((Activity) message);

      

My emulator opens a new conversation in the same chat window

+4


source to share


4 answers


Bot Framework Channel Emulator

had the features you needed in previous versions. In latest AFAIK, changing user id and group chat is not available out of the box. However, the good thing is what this tool does - it just sends http requests to your endpoint WebApi

. This means that you can catch these requests with Fiddler

or any other similar tool and then edit and reissue the request. This is a workaround, but for testing abscesses, I believe this approach can be used.

Below is the Fiddler screen and the debug session screen to show that it is working:

Fiddler Retry Request



Activity variable value during debugging

If you want to go ahead and automate it, the botframework site has REST Api documentation for you to create your own client.

+2


source


I am working on a Bot Framework emulator. We recently added the ability to override generated custom IDs for use in conversations without using a tool like Fiddler. You can use this feature in our latest release . I hope you find this useful for your scenario.



+2


source


I don't know a way to have multiple conversations with different users, but you cannot change the id / name of the user who is currently sending messages.

You can do this by editing the configuration file that the emulator uses to save its settings.

On linux, I found this settings file here: ~/.config/botframework-emulator/botframework-emulator/server.json

In this json file you will find the "users" section.

Change this section to:

"users": {
    "currentUserId": "default-user2",
    "usersById": {
      "default-user": {
        "id": "default-user",
        "name": "User"
      },
      "default-user2": {
        "id": "default-user2",
        "name": "User2"
      }
    }

      

You will need to restart the emulator and then your conversation should be with User2 now instead of User.

If you want to change it back, you just need to change:

"currentUserId": "default-user2",

      

back to

"currentUserId": "default-user",

      

0


source


In windows do the following:

  • go to% APPDATA% \ botframework-emulator \ botframework-emulator directory

  • find the server.json file

  • In the user sections, replace the default user with id, you need (in my case romel) "users": {"currentUserId": "default-user", "usersById": {"default-user": {"id": "romel "," name ":" User "}}}

  • restart the bot emulator

0


source







All Articles