There are several pieces to this framework we will need to understand before we can build our bot.
Bot Builder SDK
The Bot Builder SDK is available on GitHub. It provides samples of different dialogs that can be used with Node.js or .NET which is what I will be using.
Bot Framework Developer Portal
The Bot Framework Developer Portal lets you connect your bot(s) seamlessly text/sms to Skype, Slack, Facebook Messenger, Kik, Office 365 mail and other popular services. Simply register your bot, configure desired channels and publish in the Bot Directory. All bots registered with Bot Framework are auto-configured to work with Skype and the Web.
Bot Directory
The Bot Directory is a public directory of all reviewed bots registered through the Developer Portal. Users will be able to discover, try, and add bots to their favorite conversation experiences from the Bot Directory. If you want users to be able to download and integrate their bot into apps like Skype, this is where you will list your bot.
Getting Started with .NET
Before we begin development there are a couple of things we will need to get started. First I would recommend you download and install the Bot Framework Channel Emulator which will let you test and debug your application. Next you want to get the Connector for visual studio.
Once you have these 2 things in place you should be able to create a new blank application using the Bot Application Template.
You should get some base code that looks like this.
[BotAuthentication]
public class MessagesController : ApiController
{
<summary>
POST: api/Messages
Receive a message from a user and reply to it
</summary>
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
if (activity.Type == ActivityTypes.Message)
{
// calculate something for us to return
int length = (activity.Text ?? string.Empty).Length;
// return our reply to the user
Activity reply = activity.CreateReply($"You sent {activity.Text} which was {length} characters");
await connector.Conversations.ReplyToActivityAsync(reply);
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
}
Next week will dive in and begin examining different ways to interact with our users.
Doug Routledge, C# Lync, Skype for Business, SQL, Exchange, UC,
Full Stack Developer BridgeOC Bridge Operator Console Twitter - @droutledge @ndbridge |
No comments:
Post a Comment
Any spam comments will be deleted and your user account will be disabled.