c# - How to connect with bot from another app?


I have created a core bot with basic workflow to collect information from end-users, which is hosted on http://localhost:3978, and exposes an endpoint to send message http://localhost:3978/api/messages (POST)

I can start and chat with bot via Bot Framework Emulator, but I dont know how to interact with it via CodeBehind, or from another web application. I read some information about Direct Line API but I am still quite confused.

Could I implement my own Direct Line API to connect with my bot? Is there any samples to interact with bot from another application? Is there direct ways to connect with bot?

Please sorry if any typo misstakes.

1 Answer: 

You can connect to the bot using the Directline REST API, but it would be much easier to implement WebChat into your app. There are TONS of samples to help you get started.

Emulator is just an Electron app that uses WebChat.

Quick Start:

  1. Clone the Getting Started Sample
  2. Get your WebChat Secret from Azure Portal > Resource Group > Web App Bot > Channels

enter image description here

  1. Edit this part of the index.html:
const res = await fetch('https://webchat-mockbot.azurewebsites.net/directline/token', { method: 'POST' });
const { token } = await res.json();

To just:

const token = '<yourWebChatSecret>`

...replacing <yourWebChatSecret> with the one you copied from Step 2.

  1. cd into the folder containing index.html and run npx serve
  2. Open the site at localhost:5000

More Articles

botframework - Few question about Microsoft Teams using bot

It is possible to force a bot to join (and listen) all teams, meetings, chats conversation in my tenant without being invited or beginning the conversation?When a member was added to a team, my bot received a "conversationUpdate" message with the member that was added in the "memberAdded" field. I w

How To Get Alexa Ranking In Java

I tried to use Java and DOM XML parser to get the Alexa ranking from below :http://data.alexa.com/data?cli=10&url=domainNameIs there any API for Alexa ranking and other useful for particular URL ?

Magento EBS payment gateway - upon redirection shows 404 page

I have developed a store and using EBS payment gateway for netbanking. It was working fine but suddenly it started showing a 404 page not found error upon redirection. After clicking confirm order the customer is never directed to the EBS page but remains on the site with the page not found message!

facebook - Unable to publish an action

I'm attempting to create a Facebook Open Graph App similar to the Washington Post Social Reader, which will announce in a person's news feed when they read an article on my website, www.zeitlife.co.uk.I have followed the Open Graph tutorial closely, identifying an action and an object, and creating

javascript - Sending HTTP Requests Through Azure

I am trying to interact with Urbanairship via their broadcast API to send notifications to android devices on an INSERT into a Azure table.My JavaScript INSERT code on Azure is as follows: function insert(item, user, request) { request.execute({ success: function() {

c# - Microsoft Bot Framework works locally, but fails remotely

I have this bot that is fairly complicated, but it works locally. But as soon as I publish it, it fails with the error: Sorry, my bot code is having an issue.I have tried using Application Insights, but it isn't showing the error details.The error always happens at the same point:/// <summary>

java - How to integrate KNET payment gateway with php

How can I integrate the KNET payment gateway with PHP? The gateway id only works with Java and .NET.

android - Google Actions does not work from OK Google. my app is not recognised

I have downloaded this basic example from google: https://github.com/actions-on-google/appactions-fitness-kotlinNow if I do: adb shell am start -a android.intent.action.VIEW -d "https://fit-actions.firebaseapp.com/start"It will start my app. And the deeplink is being recognized.The example shows tha

payflowpro - How to use paypal payflow api to charge sale in canadian dollars

I have a custom application that is integrated with the paypal payflow API. We are expanding to Canada and would like to charge in the Canadian dollar for our Canadian customers but it keeps defaulting to the US Dollar.I'm trying to pass 'CURRENCY'=> 'CAD' in the REST call via curl. I can't find a

botframework - Ms Teams Bot Icon is not displayed

I've used app studio from MS Teams to creat a manifest for a Bot App. I've uploaded the full color picture as well as trasparent outlone. However the icon is not displaying at the chat window. Only the default icon is visivle. Any ideas, how can I solve the issue? Thanks a lot!