Nuget package which allows connecting to the Megafon VATS service and registers endpoints for callbacks
- Install Skytecs.MegafonPbxApiClient NuGet package
- Add namespace reference to your Startup.cs
using Skytecs.MegafonPbxApiClient;
- Place this code in your
ConfigureServices
method:
services.AddMegafonApi(options =>
{
options.ApiToken = "your-api-key";
options.PbxEndpoint = "https://your-pbx-endpoint.megapbx.ru/sys/crm_api.wcgp";
});
This code will register IMegafonApiClient
service as a singleton in the DI container.
- Add the following code to the
ConfigureServices
method.
services.AddMegafonCallbacks(options =>
{
options.OnEvent = async x =>
{
Console.WriteLine(x.Phone);
};
});
- And place this code in the
Configure
method.
app.MapMegafonCallbacks("/<relative-url-to-callbacks>", "<your-crm-token>");
Now you can provide your own implementation for any combination of the following callbacks:
OnEvent
OnHistory
OnContact