Reputation: 2680
While exploring the new preview of the botframeworkv4
in C#, I came across a case where I need to do a specific action for a certain channel. In botframeworkv3
, I used to access all the channels string names using ChannelIds
but I can't find it here.
I know that I can directly write "facebook"
for example, but using the provided list prevents any typos and improves readability.
Therefore, what is the equivalent of ChannelIds
in botframeworkv4
?
Upvotes: 8
Views: 1566
Reputation: 14589
The Channel list is available in Channels
object in Microsoft.Bot.Connector namespace:
ChannelId
is still an existing property in Activity object in v4, see sources:
/// <summary>
/// Channel this activity is associated with
/// </summary>
string ChannelId { get; set; }
The list of channelId values is still available in v4 through Microsoft.Bot.Builder.Classic
:
public sealed class ChannelIds
{
public const string Facebook = "facebook";
public const string Skype = "skype";
public const string Msteams = "msteams";
public const string Telegram = "telegram";
public const string Kik = "kik";
public const string Email = "email";
public const string Slack = "slack";
public const string Groupme = "groupme";
public const string Sms = "sms";
public const string Emulator = "emulator";
public const string Directline = "directline";
public const string Webchat = "webchat";
public const string Console = "console";
public const string Cortana = "cortana";
}
Side note: you can simply add your own list:
public enum ChannelEnum
{
emulator,
facebook,
skype,
webchat,
directline
// ...
}
and use activity.ChannelId == ChannelEnum.webchat.ToString()
Upvotes: 6
Reputation: 2680
ChannelIds
has been replaced with Channels
in the C# V4 SDK and is available under Microsoft.Bot.Connector
.
Checking for a specific channel can be done easily, for example:
var isEmail = turnContext.Activity.ChannelId == Channels.Email;
Use Nicholas R's answer if you need to add custom channels (or example Android, iOS) to the list.
Upvotes: 5