Code Monkey home page Code Monkey logo

bottranslator's Introduction

BotTranslator - Microsoft Translator with Microsoft Bot Framework

Bots are the new apps. Developers can consider this platform for consumers and commerce, reaching users via social media or through a Line Of Business (LOB) applications using embedded bots.

Multilingual support is essential for such experiences, providing a natural user interface (NUI) for last users like chatbots. In this sample we'll learn how to use Microsoft Translator in a Bot Framework Application.

In this demo "TR>EN" translation is used, Turkish as native language and English as target language. When you type your text on chat windows, your native language will be detected by API. You only need to set your target language for translation.

Deploy to Azure

Microsoft Translator Text API

To use translator in or bot service we'll use Microsoft Translator Text API. Microsoft Translator APIs can be seamlessly integrated into your applications, websites, tools, or other solutions to provide multi-language user experiences. Leveraging industry standards, it can be used on any hardware platform and with any operating system to perform language translation and other language-related operations such as text language detection or text to speech. Click Here for more information about the Microsoft Translator API

Microsoft Translator with BotFramework

Getting Started to use Microsoft Translator API

To access the Microsoft Translator Text API you will need to sign up for Microsoft Azure. Follow these steps.

  1. Sign up for a Microsoft Azure account at http://azure.com
  2. After you have an account go to http://portal.azure.com
  3. Select the + New option.
  4. Select AI + Cognitive Services from the list of services.
  5. Click See All on top right.
  6. Select Translator Text API.
  7. Select the Create button.
  8. Fill out the rest of the form.
  9. In the Pricing Tier section select the pricing tier that fits your needs.
  10. Select the Create button.
  11. You are now subscribed to Microsoft Translator.
  12. Go to All Resources and select the Microsoft Translator API you subscribed to.
  13. Go to the Keys option and copy your subscription key to access the service.

Paste this API Key into this "BotTranslator" sample in MessagesController.cs

    ...
     public class MessagesController : ApiController
     {
        string ApiKey = "PLACE YOUR MICROSOFT TRANSLATOR API KEY HERE";
        string targetLang = "en";
    ...

Prerequisites to build a new Bot using Bot Framework Application

This is a step-by-step guide to writing an Bot in C# using the Bot Framework Connector SDK .NET template.

  1. Install prerequisite software

    • Visual Studio 2015 or Visual Studio 2017 - you can download the community version here for free: http://www.visualstudio.com
    • Important: Please update all VS extensions to their latest versions Tools -> Extensions and Updates -> Updates
  2. Download and install the Bot Application template

    • Download the file from the direct download link here :
    • For VS2015: Save the zip file to your Visual Studio 2015 templates directory which is traditionally in “%USERPROFILE%\Documents\Visual Studio 2015\Templates\ProjectTemplates\Visual C
    • For VS2017: Save the zip file to your Visual Studio 2017 templates directory which is traditionally in “%USERPROFILE%\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C
  3. Open Visual Studio

  4. Create a new C# project using the new Bot Application template.

  5. The template is a fully functional Echo Bot that takes the user’s text utterance as input and returns it as output. In order to run however,

    • The bot has to be registered with Bot Connector
    • The BotID, MicrosoftAppID and MicrosoftAppPassword from the Bot Framework registration page have to be recorded in the project’s web.config
    • The project needs to be published to the web

BotID, MicrosoftAppID and MicrosoftAppPassword

Bot has unique BotID, MicrosoftAppID and MicrosoftAppPassword whenever you publish to botframework.com, it comes with default settings like below. in order to test in your bot emulator you need to make sure BotID, MicrosoftAppID and MicrosoftAppPassword are ok.

Build the sample Bot Project

  1. If you download the samples ZIP, be sure to unzip the entire archive, not just the folder with the sample you want to build.
  2. Start Microsoft Visual Studio 2015 or 2017 and select File > Open > Project/Solution.
  3. Starting in the folder where you unzipped the samples, go to the Samples subfolder, then the subfolder for this specific sample. Double-click the Visual Studio Solution (.sln) file.
  4. Press Ctrl+Shift+B, or select Build > Build Solution.

Deploying and running bot endpoint

  • To debug the bot sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or select Debug > Start Without Debugging. After that you'll see below running bot endpoint.

Running Bot Emulator

You can download Bot Emulator from http://emulator.botframework.com

After that Search "Microsoft Bot Framework Emulator" from your program and files. This will help you to test your bot endpoint before publishing it. It has a chatbot interface in order to test capabilities of your bot. And before adding a bot into conversation make sure your BotID, MicrosoftAppID and MicrosoftAppPassword are ok. Type your message and recieve the response from bot.

Have fun!

bottranslator's People

Contributors

ikivanc avatar chriswendt1 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.