ARI conferece call app: authorize / ask for pin number

I’m using a C# /.NET library to implement the Asterisk RESTful Interface (ARI) to create a conference call app.

So far the app works like this:

1.User calls the number
2.App answers
3.App starts voice detection
4.App asks for name and records the audio
5.App adds the user to the conference

I need to add in the above process some kind of authorization, before the user is added into the conference. Basically, I need to make the app ask for a PIN number and grab the pin into a variable. How can I do that?

Here’s the code:

Conference:

public Conference( AriClient c, Guid id, string name)
    {
        _client = c;
        Id = id;
        ConferenceName = name;
        State = ConferenceState.Destroyed;

        c.OnChannelDtmfReceivedEvent += c_OnChannelDtmfReceivedEvent; // ??
        c.OnBridgeCreatedEvent += c_OnBridgeCreatedEvent;
        c.OnChannelEnteredBridgeEvent += c_OnChannelEnteredBridgeEvent;
        c.OnBridgeDestroyedEvent += c_OnBridgeDestroyedEvent;
        c.OnChannelLeftBridgeEvent += c_OnChannelLeftBridgeEvent;
        c.OnRecordingFinishedEvent += c_OnRecordingFinishedEvent;

        // Added support for talk detection
        c.OnChannelTalkingStartedEvent += c_OnChannelTalkingStartedEvent;
        c.OnChannelTalkingFinishedEvent += c_OnChannelTalkingFinishedEvent;

        Debug.Print("Added Conference {0}", ConferenceName);
    }

StartConference:

public bool StartConference()
    {

        // Create the conference bridge
        Debug.Print("Requesting new bridge {0} for {1}", Id, ConferenceName);
        Bridge bridge = _client.Bridges.Create("mixing", Id.ToString(), ConferenceName);

        if (bridge == null)
        {
            return false;
        }

        Debug.Print("Subscribing to events on bridge {0} for {1}", Id, ConferenceName);
        _client.Applications.Subscribe(AppConfig.AppName, "bridge:" + bridge.Id);

        // Start MOH on conf bridge
        _client.Bridges.StartMoh(bridge.Id, "default");

        // Default state is ReadyWaiting until MOH is turned off
        State = ConferenceState.ReadyWaiting;
        Confbridge = bridge;

        // Conference ready to accept calls
        State = ConferenceState.Ready;

        return true;
    }

AddUser:

public bool AddUser(Channel c)
    {
        if (State == ConferenceState.Destroying)
            return false;
        if (State == ConferenceState.Destroyed)
        {
            // We should initiate a new conference bridge
            if (!StartConference())
                return false;
        }
        if (State < ConferenceState.Ready) return false;

        // Answer channel
        _client.Channels.Answer(c.Id);

        // Turn on talk detection on this channel
        _client.Channels.SetChannelVar(c.Id, "TALK_DETECT(set)", "");

        // Add conference user to collection
        ConferenceUsers.Add(new ConferenceUser(this, c, _client, ConferenceUserType.Normal));

        return true;
    }

From a high level perspective you would need to create your own PIN number construct within your application. Within ARI you can’t say “play back this audio file, wait for DTMF digits and when they are of this length return it”. This is an application in and of itself and ARI is about giving you the fundamentals. You need to implement that. This can be done using the normal playback ability and also looking at DTMF digits during this time (they come in as events). Once it is of sufficient length (or some other criteria is met) you’d then compare and send them on their way.

Hi and thanks for the reply.

Is this a good resource for this: ? https://wiki.asterisk.org/wiki/display/AST/ARI+and+Channels%3A+Handling+DTMF
and try to adapt it to C# ?

Yes, that page conveys the idea of what you need to do in more detail.