Direct Line API is used enable communication between your bot and your own client application.
This post will show you how can we use the direct line API of our BOT to start a conversation and also how to exchange Activities.
We are using the Microsoft Sample bot example of Notes Bot.
The below pic show how the sample conversation would go like:
Enabling the Direct line API:
Go to your Azure Portal and then Go to your Bot resource and in the menu click on the channels then enable the Direct line API for your site:
Once the Direct Line API is enabled, copy the secret key.
Starting the conversation:
Issue a POST request to start a new conversation:
Authorization: Bearer SECRET_OR_TOKEN
You will receive the Conversation Id as show below. Means the connection has been established.
Sending the Activity to the Bot:
Authorization: Bearer XXXXXXXXXXXXX
Sending a POST request:
Receiving an activity or Response from the bot:
Authorization: Bearer xxxxxxxxxx
Sending a GET Request:
Activities received is the array of the whole conversation which contains the sent activities from user and received activity from Bot.
The text sent was “create a note” and the text received is “What would like to call your note?”
So send Consecutive POST and GET request to hold a conversation with the bot.
Hope it Helps!
For full official documentation visit here
In coming posts i will try to show how can build custom chat user interface and how that custom bot can leverage the use of Direct line API.