Freigeben über


Using the Bot Framework from Python with the Direct Line API

Yes, it's possible.  The Bot Framework supports the "Direct Line" channel which you can use from any client application to call your bot.  If you want to learn more about this channel and how to call it, start here: /en-us/bot-framework/rest-api/bot-framework-rest-overview.

So assuming you've built a bot already using the Bot Builder SDK using Node.js or C#, let's take a quick look at what it's like to call your bot using Python.  Here, I will use the Direct Line API v3 referenced here: /en-us/bot-framework/rest-api/bot-framework-rest-direct-line-3-0-concepts

First up, get your development environment Python ready:

Get the code:

Then hit F5, watch your bot framework endpoint get and return a response:

*Disclaimer - I'm new to Python - in fact, this is my first attempt at it, so I'm on pretty much Hello World territory in Python-land.

Update 7th August: After some VS Code updates, I was no longer able to debug the Python code as I was seeing this error: python.python-debug.startSession' not found:

The solution was to uninstall/reinstall the Python VS Code extension and restart VS Code.

Comments

  • Anonymous
    February 20, 2018
    That's neat @Dalton!