botframeworkv4-可用频道ID列表

时间:2018-09-12 08:51:43

标签: c# botframework

在使用C#探索botframeworkv4的新预览时,我遇到一种情况,我需要为某个频道执行特定操作。在botframeworkv3中,我曾经使用ChannelIds访问所有通道的字符串名称,但在这里找不到它。

例如,我知道我可以直接写"facebook",但是使用提供的列表可以防止任何错别字并提高可读性。

因此,ChannelIds中的botframeworkv4等于什么?

2 个答案:

答案 0 :(得分:2)

<select class="form-control Dr_input Dr_select Dr_input_size" (change)="gotDevices()"> <option value="{{d}}" *ngFor="let d of devices" >{{d}}</option> </select> 仍然是v4中“活动”对象中的现有属性,请参见源:

https://github.com/Microsoft/botbuilder-dotnet/blob/master/libraries/Microsoft.Bot.Schema/IActivity.cs

ChannelId

v4到/// <summary> /// Channel this activity is associated with /// </summary> string ChannelId { get; set; } 仍提供channelId值列表:

https://github.com/Microsoft/botbuilder-dotnet/blob/master/libraries/Microsoft.Bot.Builder.Classic/Microsoft.Bot.Builder.Classic/ConnectorEx/IChannelCapability.cs

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";
}

并使用public enum ChannelEnum { emulator, facebook, skype, webchat, directline // ... }

答案 1 :(得分:0)

ChannelIds在C#V4 SDK中已替换为Channels,并且在Microsoft.Bot.Connector下可用。

可以很容易地检查特定频道,例如:

var isEmail = turnContext.Activity.ChannelId == Channels.Email;

如果您需要在列表中添加自定义渠道(或示例Android,iOS),请使用Nicholas R的答案。