1

I need to send proactive notification to the user that is scheduled at a certain time via Microsoft Bot V4. I am not exactly sure how to proceed with this.

Currently, I am trying to use Azure Function to send proactive message to user however, I'm not sure what to use to connect between bot service and azure functions. I looked at Direct Line but its not clear for me.

Currently, the best approach I can think of is to use Azure Function and Direct Line to send proactive notification to users.

I tested directline API via postman but it didn't work. It says conversational ID not found.

https://directline.botframework.com/v3/directline/conversations/{conversationId}/activities

JSON POST

{
    "type": "message",
    "from": {
        "id": "user1"
    },
    "text": "hello"
}

After the message is sent it should give me the ID.

{
    "id": "0001"
}

Edit:

I managed to understand my issue with Direct Line. It doesn't allow me to send a message to DIFFERENT channel, like Web Chat or to bot on Skype. Is there any other option to send message to my user on Skype ?

Kirol54
  • 25
  • 5
  • Did you look into https://blogs.msdn.microsoft.com/waws/2018/04/22/azure-bot-function/? – Pragna Gopa Apr 23 '19 at 21:27
  • thanks for the link ! It is useful, but still there is a bit which I don't understand, which is how to use functions to trigger proactive message that would be send to the user. So in my mind that would be a POST request to some API, and I could put it to my Azure functions so- when condition is met, send message to the user – Kirol54 Apr 24 '19 at 08:52

2 Answers2

0

You need to create output bot framework and Here is the binding information for the azure function which will be triggered after every x minute

{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */1 * * * *"
    },
    {
      "type": "bot",
      "name": "$return",
      "botId": "Azurefunction",
      "secret": "AppSettingNameOfYourBot",
      "direction": "out"
    }
  ],
  "disabled": false
}

and the azure function is

using System; using System.Net; using System.Net.Http; using Microsoft.Azure.WebJobs.Host;

public class BotMessage { public string Source { get; set; } public string Message { get; set; } }

public static BotMessage  Run(TimerInfo myTimer ,TraceWriter log)
{
    BotMessage message = new BotMessage()
    {
        Source = "AzureFunction",
        Message = "Testing"
    };
    return message;
}

Also your binding configuration is set to use the return value of your function (also, in this case, that doesn't match any of the types supported by the binding) that's how you can make a connection between Bot and azure function.

And for directline api related issue please check this thread

Cant send message using directlineapi in bot framework

Hope it helps.

Mohit Verma
  • 5,140
  • 2
  • 12
  • 27
  • Thanks for the response ! I just realized that I was working on Web App Bot rather than Function one. I just tried to create new Function bot but there is only option to use SDK v3.. Does it mean Microsoft haven't yet developed it with SDK v4? All my code is based on SDK 4 and it was quite a challenge anyway to learn Microsoft Bot framework and I started with v4. – Kirol54 Apr 24 '19 at 11:28
0

Okay so I sorted out my problem. By using REST connector https://learn.microsoft.com/en-us/azure/bot-service/rest-api/bot-framework-rest-connector-authentication?view=azure-bot-service-4.0 I think I just made big assumption that I have to use Direct Line

I maybe did not explain clear what my problem really was. Thanks for the replies !

Kirol54
  • 25
  • 5