Skip to content

Missed-call Alert API #34

@wasimfirmz

Description

@wasimfirmz

I'm trying to setup a missed call alert webhook in the makecall.cs file.

I'm trying with this code. but it is not working, can you please suggest me the right approach for this?

    private static void OnCallStateChanged(object sender, TCX.PBXAPI.CallStateChangedEventArgs e)
    {
        if (e.State == CallState.Missed || e.State == CallState.NotAnswered)
        {
            NotifyMissedCall(token: authToken, args1: e.FromExtension, args2: e.ToExtension, args3: e.CallDuration.ToString()); // Call your API to notify about the missed call
        }
    }

    private static void NotifyMissedCall(string token, string args1, string args2, string args3)
    {
        string apiUrl = "https://your-api-url/missed-call-notification";
        
        string postData = $"{{\"token\": \"{token}\", \"fromExtension\": \"{args1}\", \"toExtension\": \"{args2}\", \"callDuration\": \"{args3}\"}}";

        using (var client = new WebClient())
        {
            client.Headers[HttpRequestHeader.ContentType] = "application/json";
            string response = client.UploadString(apiUrl, "POST", postData);
            Console.WriteLine("API Response: " + response);
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions