Check conference PIN via node red

Hello,

Just to not lose discussion on our Mattermost.

Add a subroutine to your conference

Add dialplan on /etc/asterisk/extensions_extra.d/check_pin.conf:

WARNING: change/adapt the NODERED_URL to yours in the dialplan.

[conference-sylvain]
exten = s,1,Noop(Conference)
same  =   n,Read(PIN,vm-password,4)
same  =   n,Set(NODERED_URL=http://your.node.red/pin)
same  =   n,GoSub(get-via-curl,s,1(${NODERED_URL},${PIN}))
same  =   n,GotoIf($[${CURL_RESPONSE} != 200]?hangup)
same  =   n,Return()
same  =   n(hangup),Playback(vm-goodbye)
same  =   n,Hangup()

[get-via-curl]
exten = s,1,NoOp(Get info via CURL)
same  =   n,Set(CURLOPT(ssl_verifypeer)=0)
same  =   n,Set(CURLOPT(header)=1)
same  =   n,Set(CURLOPT(httptimeout)=10)
same  =   n,Set(CURLOPT(httpheader)=X_CHANNEL_ID:${CHANNEL(uniqueid)})
same  =   n,Set(CURLOPT(httpheader)=X_EXTEN:${WAZO_ENTRY_EXTEN})
same  =   n,Set(CURLOPT(httpheader)=X_CALLERID:${CALLERID(num)})
same  =   n,Set(CURLOPT(httpheader)=X_WAZO_DATA:${ARG2})
same  =   n,Set(CURLOPT(useragent)=wazo)
same  =   n,Set(CURL_RESULT=${CURL(${ARG1})})
same  =   n,Set(CURL_RESPONSE=${CUT(CURL_RESULT, ,2)})
same  =   n,Return()

Reload asterisk dialplan:

asterisk -rx 'dialplan reload'

Add to your node-red this node:

HTTP node:

The CHECK PIN function is:

const callerid = msg.req.headers.x_callerid;
const channel_id = msg.req.headers.x_channel_id;
const exten = msg.req.headers.exten;
const pin = msg.req.headers.x_wazo_data;


if (pin == '1234') {
    return [msg,null]
}

return [null,msg];

Now you can enhanced this feature by yourself. Feedback are welcome :slight_smile:

Sylvain

1 Like