4

I want to create a dialog with the bot framework. My steps:

  1. Create a new Conversation using the Direct Line API (Works without problems) (Clientside)

  2. The following Dialog gets triggered in the Bot framework (Serverside):

    bot.dialog('*:notification', [
    function (session, args) {
      builder.Prompts.text(session, args)
    },
    function (session, results) {
      logger.info('Results', results)
    }])
    
  3. I want to send a reply to the incoming Message (Clientside)

    method:'post',
    url:'conversations/' + conversationId + '/activities',
    headers:{
        'Authorization': 'Bearer' + token
    }
    body:{
        replyToId: replyToId,
        type:'message',
        from: { 
            id:'myId'
        },
        text: 'Some simple text',
        textFormat: 'plain'
    }
    

conversationId: I use the one i recieved when i created the conversation

token: I use the one i recieved when i created the conversation

replyToId: The one from the activity Object

Actual Result:

  1. The Botframework does not recognize that this is the reply to the message send and triggers the default handler.

Expected Result:

  1. The Bot Framework triggers the second step of the Dialog.
Tomasz Mularczyk
  • 34,501
  • 19
  • 112
  • 166
FLG
  • 41
  • 2
  • I am having the exact same problem with the C# DirectLineClient. Hoping the answer applies to both, but at least in the meantime know you aren't alone. – bojingo Feb 28 '18 at 04:55
  • I think that there is something wrong with the HTTP call. Somehow the replyToId gets ignored. Probably I need send it in another way. I found for the rest api integration on the server side. But nothing similar for the client side: https://learn.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-send-and-receive-messages – FLG Mar 02 '18 at 11:56
  • UPDATE TO MY COMMENT: In my case, the problem was simply that I was re-generating the from:id with each new message... so yeah, the bot didn't think my reply to the prompt was coming from the same person. Doh! Maybe something like that is at play for the original poster? – bojingo Mar 02 '18 at 14:01
  • @bojingo how does your request look like? How do you send to reply to id? The bot framework still creates a new dialog in my application. – FLG Mar 05 '18 at 06:36
  • @FLG are you still running into this problem? Just to verify, but are the addresses and the conversationId the same in the second response from the user as when the bot responds to the user the first time? – Steven G. Mar 28 '18 at 19:01

1 Answers1

2

For the first thing, your dialog '*:notification' don't have a triggerAction, you can for example modify your dialog like this:

bot.dialog('*:notification', [
    function (session, args) {
      builder.Prompts.text(session, args)
    },
    function (session, results) {
      logger.info('Results', results)
}]).triggerAction({matches: /^notification/i});

Then you may use DL to send message from your client side to your bot and trigger this dialog like this:

method:'post',
url:'conversations/' + conversationId + '/activities',
headers:{
    'Authorization': 'Bearer' + token
}
body:{
    type:'message',
    from: { 
        "id": "1234",
        "firstname": "fname",
        "lastname": "lname"
    },
    text: 'notification',
    textFormat: 'plain'
}
Grace Feng
  • 16,564
  • 2
  • 22
  • 45
  • I start the Dialog by using "bot.beginDialog(address, '*:notification')" which works without any problems and also the first function gets executed and sends a message which i recieve over direct line. The issue is that as soon as I reply to the message, a new Dialog is initiated. I think there is a issue on how i send the reply to id from the client to the server. – FLG Feb 27 '18 at 10:30