Embed a bot in an app

APPLIES TO: SDK v4

Although bots most commonly exist outside of apps, they can also be integrated with apps. For example, you could embed a knowledge bot within an app to help users find information that might otherwise be challenging to locate within complex app structures.

You can embed a bot within a help desk app to act as the first responder to incoming user requests. The bot can independently resolve simple issues and hand off more complex issues to a human agent.

Integrating bot with app

The way to integrate a bot with an app varies depending on the type of app.

Native mobile app

An app that's created in native code can communicate with the Bot Framework by using the Direct Line API, either via REST or web sockets.

Web-based mobile app

A mobile app built with a web language and frameworks such as Cordova may communicate with the Bot Framework by using the same components that a bot embedded within a website would use, just encapsulated within a native app's shell.

IoT app

An IoT app can communicate with the Bot Framework by using the Direct Line API.

In some scenarios, it may also use Azure AI services like Speech, Translator, Language, and Vision.

Other types of apps and games

Other types of apps and games can communicate with the Bot Framework by using the Direct Line API.

Creating a cross-platform mobile app that runs a bot

This example of creating a mobile app that runs a bot uses Xamarin, a popular tool for building cross-platform mobile applications.

First, create a web view component and use it to host a Web Chat control. Then, using Azure portal, add the Web Chat channel.

Next, specify the registered web chat URL as the source for the web view control in the Xamarin app:

public class WebPage : ContentPage
{
public WebPage()
    {
        var browser = new WebView();
        browser.Source = "https://webchat.botframework.com/embed/<YOUR SECRET KEY HERE>";
        this.Content = browser;
    }
}

Using this process, you can create a cross-platform mobile application that renders the embedded web view with the web chat control.

Examples of a bot recognizing what type of device the user's on.

Additional resources