Connect a bot to the Web Talk channel – Bot Framework, Microsoft Docs

Connect a bot to the Web Talk channel – Bot Framework, Microsoft Docs

Connect a bot to Web Talk

When you register a bot with the Bot Framework, the Web Talk channel is automatically configured for you. The Web Talk channel includes the web talk control, which provides the capability for users to interact with your bot directly in a web page.

The Web Talk channel in the Bot Framework Portal contains everything you need to embed the web talk control in a web page. All you have to do to use the web talk control is get your bot's secret key and embed the control in a web page.

To see how various Bot Framework features look and work on this channel, use the Channel Inspector.

Get your bot secret key

Select your bot.

Under Channels on the bot dashboard, click Edit for the Web Talk channel.

Click Add fresh site, name your site, and click Done.

Under Secret keys, click Display for the very first key.

Embed the web talk control in your website

You can embed the web talk control in your website by using one of two options.

Option one – Keep your secret hidden, exchange your secret for a token, and generate the embed

Use this option if you can execute a server-to-server request to exchange your web talk secret for a makeshift token, and if you want to make it difficult for other developers to embed your bot in their websites. Albeit using this option will not absolutely prevent other developers from embedding your bot in their websites, it does make it difficult for them to do so.

To exchange your secret for a token and generate the embed:

Issue a GET request to https://webchat.botframework.com/api/tokens and pass your web talk secret via the Authorization header. The Authorization header uses the BotConnector scheme and includes your secret, as shown in the example request below.

The response to your GET request will contain the token (surrounded with quotation marks) that can be used to commence a conversation by rendering the web talk control within an iframe. A token is valid for one conversation only; to embark another conversation, you must generate a fresh token.

Within the iframe Embed code that you copied from the Web Talk channel within the Bot Framework Portal (as described in Step one above), switch the s= parameter to t= and substitute "YOUR_SECRET_HERE" with your token.

Tokens will automatically be renewed before they expire.

Example request
Example response
Example iframe (using token)

Option two – Embed the web talk control in your website using the secret

Use this option if you want to permit other developers to lightly embed your bot into their websites.

Warning

If you use this option, other developers can embed your bot into their websites by simply copying your embed code.

To embed your bot in your website by specifying the secret within the iframe tag:

Copy the iframe Embed code from the Web Talk channel within the Bot Framework Portal (as described in Step one above).

Within that Embed code, substitute "YOUR_SECRET_HERE" with the Secret key value that you copied from the same page.

Example iframe (using secret)

Style the web talk control

You may switch the size of the web talk control by using the style attribute of the iframe to specify height and width .

Extra resources

You can download the source code for the web talk control on GitHub.

Related video:

Leave a Reply

Your email address will not be published. Required fields are marked *