How to respond to a message from the Bot Framework (Direct Line Client)?

I want to create a dialogue with the base of bots. My steps:

  • Create a new dialog using the straight line API (works without problems) (Clientside)

  • In the Bot (Serverside) structure, the following dialog starts:

    bot.dialog('*:notification', [
    function (session, args) {
      builder.Prompts.text(session, args)
    },
    function (session, results) {
      logger.info('Results', results)
    }])
    
  • I want to send a response to an 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'
    }
    

talkId: I use the one that was received when creating the conversation

token: I use the one that was received when creating the conversation

replyToId: one of the Activity object

Actual result:

  1. Botframework does not recognize that it is a response to the send message and starts the default handler.

Expected Result:

  1. The Bot platform launches the second step of the dialogue.
+4
source share
1 answer

-, '*:notification' triggerAction, , , :

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

DL :

method:'post',
url:'conversations/' + conversationId + '/activities',
headers:{
    'Authorization': 'Bearer' + token
}
body:{
    type:'message',
    from: { 
        "id": "1234",
        "firstname": "fname",
        "lastname": "lname"
    },
    text: 'notification',
    textFormat: 'plain'
}
+1

Source: https://habr.com/ru/post/1694134/


All Articles