Skip to content
This repository has been archived by the owner on Nov 26, 2019. It is now read-only.

Channel Microsoft Bot Framework

Jerome Houdan edited this page Jun 28, 2017 · 1 revision

Microsoft Bot Framework

Setup your Microsoft Bot Framework account

Login on Microsoft

Go on Microsoft Bot Framework and create an account.

Create a new bot

Once you are logged in, click on My bots in the header and then on Create a bot.

Microsoft

Fill in the fields appearing in the pop-up window, such as the name of your bot and a description.

In the Configuration section, click on Create Microsoft App ID and password to create a new app linked to your bot.

Microsoft

A new window opens. Fill in the form below with the App Id and password, then click on Finish and go back to Bot Framework.

Microsoft

Finally, click on Register to create your bot.

Microsoft

Start Connector in local

  • Clone and install Connector
$ git clone https://github.com/RecastAI/bot-connector.git
$ cd bot-connector
$ yarn install
$ yarn start-dev
  • Create your connector
$ curl -X POST "http://localhost:8080/connectors/" --data "url=connector_url"
  • Create your channel
$ curl -X  POST \
  --data "slug=YOUR_CHANNEL_SLUG" --data "type=microsoft" \
  --data "clientId=MICROSOFT_CLIENT_ID" --data "clientSecret=MICROSOFT_CLIENT_SECRET" \
  "http://localhost:8080/connectors/:connector_id/channels"

Your bot

A small example of bot:

 import express from 'express'
 import bodyParser from 'body-parser'
 import request from 'superagent'
 
 const app = express()
 app.set('port', process.env.PORT || 5000)
 app.use(bodyParser.json())
 
 const config = { url: 'http://localhost:8080', connectorId: 'yourConnectorId' }
 
   /* Get the request from the connector */
 
 app.post('/', (req, res) => {
   const conversationId = req.body.message.conversation
   const messages = [{
     type: 'text',
     content: 'my first message',
   }]
 
   /* Send the message back to the connector */
   request.post(`${config.url}/connectors/${config.connectorId}/conversations/${conversationId}/messages`)
     .send({ messages, senderId: req.body.senderId })
     .end((err, res) => {
       if (err) {
         console.log(err)
       } else {
         console.log(res)
       }
     })
 })
 
 app.listen(app.get('port'), () => {
   console.log('Our bot is running on port', app.get('port'))
 })
Clone this wiki locally