0
votes

I have a Microsoft Bot Framework v4 bot. It has a Twilio SMS channel. Both work. My goal is to add a second Twilio SMS phone number that points to the same bot.

I wrote the code in the server to read the RecipientId and RecipientName. I want the server to recognize which number the user texted to and respond depending on that data.

I wrote a class (MyBotCredentialProviderStd) which implements ICredentialProvider. It allocates and stores a SimpleCredentialProvider instance and passes calls through to that object. When it receives a IsValidAppIdAsync call it compares the app id to a (for now) static value corresponding to a second bot registration for the same server app. If match, return true. If not match, call the MS class. Same for the GetAppPasswordAsync method.

This code works. I can send text messages to the two Twilio SMS messages. The server reads the target phone number and replies.

Is there a way to do this in the Azure Portal? Is there a better or simpler approach?

Thanks,

Adam Leffert www.leffert.com

1

1 Answers

0
votes

Is there a way to do this in the Azure Portal?

Unfortunately, no. Each Web App Bot/Bot Channels Registration can only be associated with one Twilio number.

Is there a better or simpler approach?

The approach you're using is probably the easiest. The only other viable option that I can think of would be to use the Twilio SMS API. The flow would be something like this:

  1. Create a server running the Twilio SMS API code that basically just forwards the messages to the bot via the DirectLine API. User sends a message to this server

  2. To each activity sent to the bot, include the number: Activity.ChannelData = new { fromNumber: <555-555-5555> }. Server forwards the message to the bot

  3. Handle the activity within your bot, and re-attach the fromNumber to the bot's outgoing activity so that your Twilio API server knows where to send the outgoing message to. Bot sends the reply to the server

  4. And then have the Twilio API server send Activity.Text to the user. Server forwards message from bot to user

Again, the route you're using is likely the easiest to develop and also maintain.