DirectLineAPI – Testing with custom client and POSTMAN – Microsoft Bot Framework

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:

Notes Bot Sample Conversation

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:

configure the Direct Line and generate the secret key 

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

Add the Authorization header and click on send

You will receive the Conversation Id as show below. Means the connection has been established.


Sending the Activity to the Bot:

Authorization: Bearer XXXXXXXXXXXXX
Content-Type: application/json
[other headers]

Sending a POST request:

sending an activity with a custom body
You will receive the response as conversation Id

Receiving an activity or Response from the bot:


Authorization: Bearer xxxxxxxxxx

Sending a GET Request:

Send a GET request to receive the Bot response
Received response from the BOT

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.


One thought on “DirectLineAPI – Testing with custom client and POSTMAN – Microsoft Bot Framework

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s