Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Fixed originated call log
Version log on start up
  • Loading branch information
serfreeman1337 committed Jan 7, 2020
1 parent 72bcff7 commit b64d274
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 29 deletions.
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ To monitor how call is going this connector listens for AMI events.
There should be 4 **different** contexts to distinguish calls:
* incoming_context
* outgoing_context
* ext_context - to call extension from direct, queue or ring group
* ext_context - extensions dials from queue, ring group
* dial_context - for originate

Default configuration is tested to work with FreePBX v14 and Asterisk v13.
### CallerID Format
Connector can format CallerID using regexp. This useful when your VoIP provider doesn't send desired format.

* cid_format - from PBX to CRM
* dial_format - from CRM to PBX
* *expr* - regual expression (use double blackslashes)
* *repl* - replace pattern

If config is set and callerid doesn't matched any of regexp, then call will be ignored.
## Bitrix24 Integration
### Basic setup
* Bitrix24 -> Applications -> Webhooks -> Add inbound webhook
Expand All @@ -33,4 +42,14 @@ exten => route,1,Set(B24ASSIGNED=${CURL(http://my_endpoint_addr/assigned/${UNIQU
same => n,GotoIf($[${B24ASSIGNED}]?from-did-direct,${B24ASSIGNED},1)
same => n,Goto(ext-queues,400,1)
same => n,Hangup
```
```
### Recording upload
Bitrix24 can download and store call recording.
* Make your recording folder accessible. From webserver, for example:
```
ln -s /var/spool/asterisk/monitor /var/www/html/recfiles
```
* Set **rec_upload** url in config
```
http://my_pbx_addr/recfiles/
```
43 changes: 21 additions & 22 deletions conf.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ami:
host: localhost
user: admin
pass: admin
port: 5038
# port: 5038
dialplan:
incoming_context:
- from-pstn
Expand All @@ -14,29 +14,28 @@ dialplan:
- macro-dial-one
- macro-dial
dial_context: from-internal
pbx:
dids:
- '561600'
- '561610'
- '561620'
cid_format:
- {expr: "^\\d{9}$", repl: "+998$0"}
- {expr: "^\\d{7}$", repl: "+99878$0"}
dial_format:
- {expr: "^(\\+|)998(\\d{9})$", repl: "$2"}
vote_ivr: "ivr-1"
# pbx:
# dids:
# - '561600'
# - '561610'
# - '561620'
# cid_format:
# - {expr: "^\\d{9}$", repl: "+998$0"}
# - {expr: "^\\d{7}$", repl: "+99878$0"}
# dial_format:
# - {expr: "^(\\+|)998(\\d{9})$", repl: "$2"}
bitrix24:
default_user: "1"
webhook_url: https://mycrm.bitrix24.eu/rest/1/mytoken/
webhook_originate_token: my_originate_token
webhook_endpoint_addr: "127.0.0.1:5678"
rec_upload: "http://mypbx.example.org/recfiles/"
search_format:
- {expr: ".*", repl: "$0"}
- {expr: "^\\+(\\d{5})(\\d{7})$", repl: "+$1 $2"} # +XXXXX XXXXXXX
- {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "+$1 $2 $3 $4"} # +XXXXX XXX XX XXX
- {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "+$1 $2-$3-$4"} # +XXXXX XXX-XX-XXX
- {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "$1 $2-$3-$4"} # XXXXX XXX XX XX
- {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "$2 $3 $4"} # XXX XX XX
- {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "$2-$3-$4"} # XXX-XX-XX
- {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "(+$1) $2-$3-$4"} # (+XXXXX) XXX-XX-XX
# rec_upload: "http://mypbx.example.org/recfiles/"
# search_format:
# - {expr: ".*", repl: "$0"}
# - {expr: "^\\+(\\d{5})(\\d{7})$", repl: "+$1 $2"} # +XXXXX XXXXXXX
# - {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "+$1 $2 $3 $4"} # +XXXXX XXX XX XXX
# - {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "+$1 $2-$3-$4"} # +XXXXX XXX-XX-XXX
# - {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "$1 $2-$3-$4"} # XXXXX XXX XX XX
# - {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "$2 $3 $4"} # XXX XX XX
# - {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "$2-$3-$4"} # XXX-XX-XX
# - {expr: "^\\+(\\d{5})(\\d{3})(\\d{2})(\\d{2})$", repl: "(+$1) $2-$3-$4"} # (+XXXXX) XXX-XX-XX
16 changes: 11 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,17 @@ func (c *conf) getConf() {
}
}

var (
version string
build string
compiled string
)

func init() {
log.SetFormatter(&log.TextFormatter{})
log.SetOutput(os.Stdout)

log.Info("AsterLink v. 0.1.0-dev")
log.WithFields(log.Fields{"ver": version, "build": build, "compiled": compiled}).Info("AsterLink")
}

func main() {
Expand Down Expand Up @@ -341,7 +347,7 @@ func main() {

cID, ok := formatNum(e["ConnectedLineNum"], true)
if !ok {
log.WithFields(log.Fields{"lid": e["Linkedid"], "cid": e["CallerIDNum"]}).Warn("Unknown outgoing CallerID")
log.WithFields(log.Fields{"lid": e["Linkedid"], "cid": e["ConnectedLineNum"]}).Warn("Unknown outgoing CallerID")
return
}

Expand All @@ -358,7 +364,6 @@ func main() {
Log: log.WithField("lid", e["Linkedid"]),
}

// fmt.Println(e)
cdr[e["Linkedid"]].Log.Debug("New outgoing call")

return
Expand Down Expand Up @@ -552,8 +557,9 @@ func main() {
// originated call
ami.RegisterHandler("VarSet", func(e map[string]string) {
c, ok := cdr[e["Linkedid"]]
if !ok { // VarSet for originated call
if e["Exten"] == "failed" {
if !ok {
// VarSet for originated call
if e["Variable"] != "SF_CONNECTOR" || e["Exten"] == "failed" {
return
}

Expand Down

0 comments on commit b64d274

Please sign in to comment.