A relay utility for bots based on Azure Relay.
This utility allows you to forward a message sent to a bot hosted on any channel to your local machine.
It is useful for debug scenarios or for more complex situations where the BotEmulator is not enough (i.e.: you use the WebChat control hosted on a site and you need to receive ChannelData in your requests or you are testing Teams specific events).
It uses the Azure Relay service along with a small local service to recieve messages from the bot service and forward them to your locally hosted bot. This service can be hosted with the command line tool or installed into your Bot Composer bot as an Adapter package from Nuget.
Part of this code is based on the work that Pedro Felix and Gabo Gilbert have previously done
The relay can be used with traditional code based bots or as a simple add in component to Bot Composer
To setup the Azure Bot Service to connect to your local bot you need to
- Deploy an Azure Relay service
- Configure your Azure Bot Service to send messages to the Azure Relay
- Connect to the relay from Bot Composer
- If you are using a code only bot and not using Bot Composer, once you set up the Azure Service Bus Relay, see the command line instructions to connect it to your bot)
You can use this button to deploy an Azure Relay service with the correct configuration. You will just need to supply it with a unique name for the Azure Service Bus namespace.
After it completes, select the Outputs tab and copy the 5 values. You will need those to configure the bot relay tool and your bot service.
If you want to deploy the relay service manually you will need to
- ensure the relay does not require authentication
- add a shared access policy to the hybrid relay that has permission to send & listen
Before testing the relay, your Azure Web App Bot's messaging endpoint must be updated to match the relay.
-
Login to the Azure portal and open your Web App Bot or Bot Registration.
-
Select Settings under Bot management to open the settings blade.
-
In the Messaging endpoint field, enter the service bus namespace and relay. This is the "messagingEndpoint" value from the output of the deployment step above.
Ensure that the URI ends with "/api/messages"
For example, “https://example-service-bus.servicebus.windows.net/hc1/api/messages".
-
Click Save when completed. (You might have to click save twice)
- Add the NegativeEddy.Bots.AzureServiceBusRelay.Adapter package to your bot
- Enable the bot in the External Connections section and fill in the options from the values captured when you deployed the Azure Service Bus
- Restart your bot
- Test your bot on a channel (Test in Web Chat, Skype, Teams, etc.).