botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

How to call into the Direct Line REST api?

Open wbreza opened this issue 10 years ago • 16 comments

What is the base url for the Direct Line REST api? Reviewing the docs from http://docs.botframework.com/sdkreference/restapi-directline/#navtitle is not very clear and the demo form attempts to test with localhost.

wbreza avatar Apr 05 '16 05:04 wbreza

it is api.botframework.com

tomlm avatar Apr 05 '16 23:04 tomlm

Thanks - I've tried the following with no success. I'm attempting to start a new conversation using the direct line REST API passing in the secret from my bots direct line secret obtained from the portal.

Request POST - https://api.botframework.com/api/conversations Authorization: BotConnector {secret}

Response HTTP/1.1 404 Resource Not Found Content-Length: 54 Content-Type: application/json Date: Wed, 06 Apr 2016 01:56:31 GMT

{ "statusCode": 404, "message": "Resource not found" }

Am I missing anything else?

wbreza avatar Apr 06 '16 02:04 wbreza

@tomlm ping - See question above.

wbreza avatar Apr 16 '16 00:04 wbreza

Sorry, we misspoke earlier. The hostname for the Direct Line API is directline.botframework.com. The api.botframework.com hostname is where the main Bot Connector API is located.

dandriscoll avatar Apr 16 '16 04:04 dandriscoll

Hi guys, I have a question: I have custom storage for my bot, configured through the ChatConnector, ie replaced state.botframework.com with a custom endpoint; our client uses direct client api; does direct line store data, maybe temporarily? I mean, when I start a conversation, then invoke get messages, it appears direct line gives me messages without hitting my bot connector's api getData, which makes me think it somehow has received it at some point through some interaction direct-line and my bot app; is there a way to know how the whole flow works? I also invoked get message directly for a conversationId: userMessageSet = userConversations.GetMessages(conversationId); and it didn't hit the bot connector from my app at all, which seems to tell that direct client (https://directline.botframework.com) somehow stored or cached the answer to a previous conversation. Thanks.

alin-nemet avatar Nov 03 '16 16:11 alin-nemet

Hi @alin-nemet, that's correct, the Direct Line service has a temporary message store so that clients can retrieve the message history. We use a cental store because the bot can send messages at any time but the client has no webhook to receive callbacks.

dandriscoll avatar Nov 03 '16 20:11 dandriscoll

Thx a lot!

alin-nemet avatar Nov 03 '16 20:11 alin-nemet

And how does a Bot send a message to the Directline? What service URL should I use then?

vaibhavkapur avatar Jun 23 '17 10:06 vaibhavkapur

I want to a send a message to an existing conversation between my bot and the directline client. I have the conversation ID. How do I do that? Using what service URL?

vaibhavkapur avatar Jun 23 '17 10:06 vaibhavkapur

Hi,

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-direct-line-3-0-concepts

Don’t worry about sending a message to direct line, just treat your bot as you would any other channel. I haven’t used Direct Line in a while, but I will assume that it will be the same URL as activity.ServiceURL. The service URL of the activity

Regards Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 23 June 2017 10:46 To: Microsoft/BotBuilder Cc: Subscribed Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

And how does a Bot send a message to the Directline? What service URL should I use then? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

michaelhutchful avatar Jun 23 '17 10:06 michaelhutchful

Hi,

My Scenario is this:

My Bot is connected to both the Webchat and Directline channel. I know the details(id, name, conversationID) of the user in the Directline channel.

Once the user of the Webchat channel sends a particular message(say "123456"), I want to send the same message to the user of Directline Channel.

On Fri, Jun 23, 2017 at 4:23 PM, michaelhutchful [email protected] wrote:

Hi,

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot- framework-rest-direct-line-3-0-concepts

Don’t worry about sending a message to direct line, just treat your bot as you would any other channel. I haven’t used Direct Line in a while, but I will assume that it will be the same URL as activity.ServiceURL. The service URL of the activity

Regards Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 23 June 2017 10:46 To: Microsoft/BotBuilder Cc: Subscribed Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

And how does a Bot send a message to the Directline? What service URL should I use then? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/54#issuecomment-310635901, or mute the thread https://github.com/notifications/unsubscribe-auth/AcKeJXT469_CyLxxREnzMpByU5dniq_Vks5sG5k2gaJpZM4H_vwY .

vaibhavkapur avatar Jun 24 '17 07:06 vaibhavkapur

When you send the message to direct line, use the following

Activity replyMessage = webChatActivity;

var connector = new ConnectorClient(new Uri(directLineActivity.ServiceUrl)); replyMessage.Text = "123456”; replyMessage.Type = ActivityTypes.Message; replyMessage.ReplyToId = directLineActivity.From.Id; replyMessage.From = directLineActivity.Recipient;

await connector.Conversations.ReplyToActivityAsync(replyMessage);

I will use something like this. You will need to save the activity from DirectLine and use the details to send the message you receive from Webchat.

Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 24 June 2017 07:47 To: Microsoft/BotBuilder Cc: michaelhutchful; Comment Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

Hi,

My Scenario is this:

My Bot is connected to both the Webchat and Directline channel. I know the details(id, name, conversationID) of the user in the Directline channel.

Once the user of the Webchat channel sends a particular message(say "123456"), I want to send the same message to the user of Directline Channel.

On Fri, Jun 23, 2017 at 4:23 PM, michaelhutchful [email protected] wrote:

Hi,

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot- framework-rest-direct-line-3-0-concepts

Don’t worry about sending a message to direct line, just treat your bot as you would any other channel. I haven’t used Direct Line in a while, but I will assume that it will be the same URL as activity.ServiceURL. The service URL of the activity

Regards Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 23 June 2017 10:46 To: Microsoft/BotBuilder Cc: Subscribed Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

And how does a Bot send a message to the Directline? What service URL should I use then? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/54#issuecomment-310635901, or mute the thread https://github.com/notifications/unsubscribe-auth/AcKeJXT469_CyLxxREnzMpByU5dniq_Vks5sG5k2gaJpZM4H_vwY .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

michaelhutchful avatar Jun 24 '17 09:06 michaelhutchful

Hi Micheal,

Thanks for the reply, but I am not getting a message from the DirectLine user, hence can not use the ReplyToActivity method. What I can do is use the SendToConversation method, because I know the conversationId of the interaction with the Directline user. This will be done once the Webchat user enters a specific message.

But, I am error doing this. Does my Bot require Directline secret key for sending the message?

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-send-and-receive-messages

On Sat, Jun 24, 2017 at 3:26 PM, michaelhutchful [email protected] wrote:

When you send the message to direct line, use the following

Activity replyMessage = webChatActivity;

var connector = new ConnectorClient(new Uri(directLineActivity.ServiceUrl) ); replyMessage.Text = "123456”; replyMessage.Type = ActivityTypes.Message; replyMessage.ReplyToId = directLineActivity.From.Id; replyMessage.From = directLineActivity.Recipient;

await connector.Conversations.ReplyToActivityAsync(replyMessage);

I will use something like this. You will need to save the activity from DirectLine and use the details to send the message you receive from Webchat.

Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 24 June 2017 07:47 To: Microsoft/BotBuilder Cc: michaelhutchful; Comment Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

Hi,

My Scenario is this:

My Bot is connected to both the Webchat and Directline channel. I know the details(id, name, conversationID) of the user in the Directline channel.

Once the user of the Webchat channel sends a particular message(say "123456"), I want to send the same message to the user of Directline Channel.

On Fri, Jun 23, 2017 at 4:23 PM, michaelhutchful <[email protected]

wrote:

Hi,

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot- framework-rest-direct-line-3-0-concepts

Don’t worry about sending a message to direct line, just treat your bot as you would any other channel. I haven’t used Direct Line in a while, but I will assume that it will be the same URL as activity.ServiceURL. The service URL of the activity

Regards Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 23 June 2017 10:46 To: Microsoft/BotBuilder Cc: Subscribed Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

And how does a Bot send a message to the Directline? What service URL should I use then? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/Microsoft/BotBuilder/issues/54# issuecomment-310635901>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AcKeJXT469_ CyLxxREnzMpByU5dniq_Vks5sG5k2gaJpZM4H_vwY>

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/54#issuecomment-310829159, or mute the thread https://github.com/notifications/unsubscribe-auth/AcKeJTtGsRdGBSRJ0cAwGtGSQ-LtdKclks5sHN1HgaJpZM4H_vwY .

vaibhavkapur avatar Jun 24 '17 10:06 vaibhavkapur

Yes direct line needs a secret key

Sent from my Windows 10 phone

From: vkapur Sent: 24 June 2017 10:16 To: Microsoft/BotBuilder Cc: michaelhutchful; Comment Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

Hi Micheal,

Thanks for the reply, but I am not getting a message from the DirectLine user, hence can not use the ReplyToActivity method. What I can do is use the SendToConversation method, because I know the conversationId of the interaction with the Directline user. This will be done once the Webchat user enters a specific message.

But, I am error doing this. Does my Bot require Directline secret key for sending the message?

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-send-and-receive-messages

On Sat, Jun 24, 2017 at 3:26 PM, michaelhutchful [email protected] wrote:

When you send the message to direct line, use the following

Activity replyMessage = webChatActivity;

var connector = new ConnectorClient(new Uri(directLineActivity.ServiceUrl) ); replyMessage.Text = "123456”; replyMessage.Type = ActivityTypes.Message; replyMessage.ReplyToId = directLineActivity.From.Id; replyMessage.From = directLineActivity.Recipient;

await connector.Conversations.ReplyToActivityAsync(replyMessage);

I will use something like this. You will need to save the activity from DirectLine and use the details to send the message you receive from Webchat.

Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 24 June 2017 07:47 To: Microsoft/BotBuilder Cc: michaelhutchful; Comment Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

Hi,

My Scenario is this:

My Bot is connected to both the Webchat and Directline channel. I know the details(id, name, conversationID) of the user in the Directline channel.

Once the user of the Webchat channel sends a particular message(say "123456"), I want to send the same message to the user of Directline Channel.

On Fri, Jun 23, 2017 at 4:23 PM, michaelhutchful <[email protected]

wrote:

Hi,

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot- framework-rest-direct-line-3-0-concepts

Don’t worry about sending a message to direct line, just treat your bot as you would any other channel. I haven’t used Direct Line in a while, but I will assume that it will be the same URL as activity.ServiceURL. The service URL of the activity

Regards Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 23 June 2017 10:46 To: Microsoft/BotBuilder Cc: Subscribed Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

And how does a Bot send a message to the Directline? What service URL should I use then? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/Microsoft/BotBuilder/issues/54# issuecomment-310635901>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AcKeJXT469_ CyLxxREnzMpByU5dniq_Vks5sG5k2gaJpZM4H_vwY>

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/54#issuecomment-310829159, or mute the thread https://github.com/notifications/unsubscribe-auth/AcKeJTtGsRdGBSRJ0cAwGtGSQ-LtdKclks5sHN1HgaJpZM4H_vwY .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

michaelhutchful avatar Jun 24 '17 10:06 michaelhutchful

And is there any way to input that using the SendToConversation or any other method? It comes in the header of Request Message as the Authorization parameter, its value being "Bearer SecretKey". How do I do that in this context?

On Sat, Jun 24, 2017 at 4:00 PM, michaelhutchful [email protected] wrote:

Yes direct line needs a secret key

Sent from my Windows 10 phone

From: vkapur Sent: 24 June 2017 10:16 To: Microsoft/BotBuilder Cc: michaelhutchful; Comment Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

Hi Micheal,

Thanks for the reply, but I am not getting a message from the DirectLine user, hence can not use the ReplyToActivity method. What I can do is use the SendToConversation method, because I know the conversationId of the interaction with the Directline user. This will be done once the Webchat user enters a specific message.

But, I am error doing this. Does my Bot require Directline secret key for sending the message?

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot- framework-rest-connector-send-and-receive-messages

On Sat, Jun 24, 2017 at 3:26 PM, michaelhutchful <[email protected]

wrote:

When you send the message to direct line, use the following

Activity replyMessage = webChatActivity;

var connector = new ConnectorClient(new Uri(directLineActivity. ServiceUrl) ); replyMessage.Text = "123456”; replyMessage.Type = ActivityTypes.Message; replyMessage.ReplyToId = directLineActivity.From.Id; replyMessage.From = directLineActivity.Recipient;

await connector.Conversations.ReplyToActivityAsync(replyMessage);

I will use something like this. You will need to save the activity from DirectLine and use the details to send the message you receive from Webchat.

Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 24 June 2017 07:47 To: Microsoft/BotBuilder Cc: michaelhutchful; Comment Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

Hi,

My Scenario is this:

My Bot is connected to both the Webchat and Directline channel. I know the details(id, name, conversationID) of the user in the Directline channel.

Once the user of the Webchat channel sends a particular message(say "123456"), I want to send the same message to the user of Directline Channel.

On Fri, Jun 23, 2017 at 4:23 PM, michaelhutchful < [email protected]

wrote:

Hi,

https://docs.microsoft.com/en-us/bot-framework/rest-api/bot- framework-rest-direct-line-3-0-concepts

Don’t worry about sending a message to direct line, just treat your bot as you would any other channel. I haven’t used Direct Line in a while, but I will assume that it will be the same URL as activity.ServiceURL. The service URL of the activity

Regards Michael Hutchful

Sent from Mail for Windows 10

From: vkapur Sent: 23 June 2017 10:46 To: Microsoft/BotBuilder Cc: Subscribed Subject: Re: [Microsoft/BotBuilder] How to call into the Direct Line REST api?(#54)

And how does a Bot send a message to the Directline? What service URL should I use then? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/Microsoft/BotBuilder/issues/54# issuecomment-310635901>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AcKeJXT469_ CyLxxREnzMpByU5dniq_Vks5sG5k2gaJpZM4H_vwY>

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub <https://github.com/Microsoft/BotBuilder/issues/54# issuecomment-310829159>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ AcKeJTtGsRdGBSRJ0cAwGtGSQ-LtdKclks5sHN1HgaJpZM4H_vwY>

.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Microsoft/BotBuilder/issues/54#issuecomment-310830588, or mute the thread https://github.com/notifications/unsubscribe-auth/AcKeJbELe89BvRgcEZjq5cANVVjz-Cfuks5sHOVNgaJpZM4H_vwY .

vaibhavkapur avatar Jun 24 '17 10:06 vaibhavkapur

Hi Guys, I have configured a Web Chat Channel and a Direct Line Channel on Azure Bot Service. I am using the web chat control on the client side i.e. on a web page to provide a UI to users. For now I am using the Web chat control as it is i.e. included botchat.js in html served from my local server and also botchat.css which I have modified the css to give a custom look n feel. There will be requirement in future where I might have to create a custom build of Web Chat control source code, to reduce the overall size of botchat.js file and do some custom implementation as well. My question is it right way to use the UI for a website. Please share your experience and best practice for the same. Are there any other ways to do UI for Website, because I want to support the flexibility of displaying various types of responses like text, video, hero cards etc. Also, for now I am passing the secret key in the BotChat.App code, but I am confused which secret key to use, the one from WebChat Channel or DirectLine Channel. Please help me guys. Thanks and Cheers for your efforts..

mutanttech avatar Jan 25 '18 17:01 mutanttech