Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass calls to users #23

Open
joshuaalayon opened this issue Jan 1, 2025 · 21 comments
Open

How to pass calls to users #23

joshuaalayon opened this issue Jan 1, 2025 · 21 comments

Comments

@joshuaalayon
Copy link

joshuaalayon commented Jan 1, 2025

SuiteCRM 8.5
The asterisk is running on freepbx 17

Asterlink can see the calls... I think the issue is in the SuiteCRM Asterisk Extension, the Asterisk Extension in user profile not being picked up by the FreePBX extension. Asterlink CLI shows the user extension being loaded from SuiteCRM as 987:1 (given extension number in suitecrm gui is 987, asterlink is adding the :1)

Let me know if any logs would help please

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Jan 1, 2025

For freepbx17 you need to add "trunk-dial-with-exten" and "dialOne-with-exten" contexts in the config like that:

dialplan:
  incoming_context:
  - from-pstn
  outgoing_context:
  - macro-dialout-trunk
  - trunk-dial-with-exten
  ext_context:
  - macro-dial-one
  - macro-dial
  - dialOne-with-exten
  dial_context: from-internal

987:1 is a <extension>:<user id> mapping

@joshuaalayon
Copy link
Author

joshuaalayon commented Jan 1, 2025

Unfortunately, it still isn't passing calls to SuiteCRM, at least that I can see. Maybe I need something else installed on SuiteCRM, the only call module I have is from this one, otherwise the SuiteCRM install is completely fresh.

This is what I see when running Asterlink from CLI during a call, not sure if it helps.

./asterlink

INFO[0000] AsterLink
INFO[0000] Setting log level fields.level=debug
INFO[0000] Using SuiteCRM Connector
INFO[0000] User list updated suite=true users="map[987:1]"
INFO[0000] Enabling web server addr="0.0.0.0:5678" suite=true
INFO[0000] Established connection with AMI fields.msg="Asterisk Call Manager/10.0.0"
DEBU[0007] MixMonitor lid=1735708951.5 rec=2025/01/01/in-1**********-1**********-20250101-002231-1735708951.5.wav uid=1735708951.5
DEBU[0091] Clear recording lid=1735708951.5 uid=1735708951.5

@serfreeman1337
Copy link
Owner

What is the trunk context on freepbx ? It must be from-pstn.
image

@joshuaalayon
Copy link
Author

joshuaalayon commented Jan 1, 2025

from-pstn-toheader

I have already tried changing the incoming_context in conf.yml as well, to no avail, same behavior, same thing in Asterlink CLI. It gets the incoming phone number and DID, but no extension numbers. It does get the incoming phone number. It also does not recognize when the call is passed from the IVR, to an extension. It only recognizes when the call hits the PBX and when the call is disconnected, the callers phone number and the trunk's phone number.

Is it maybe possible to use the trunk phone number, instead of the extension number?

@serfreeman1337
Copy link
Owner

I guess your trunk provider places calls to "s" extension and so that why you need to use from-pstn-toheader.

The problem is the "s" extension is filtered here:

if /*_, ok := IncomingContext[e["Context"]]; !ok || */ e["Exten"] == "s" { // TODO: review this 's'!

You can try to "fix" it by hardcoding DID value in the code like that:

// incoming call
func (a *amiConnector) onNewchannel(e map[string]string) {
+	if a.isContext(e["Context"], a.cfg.DP.In) && e["Exten"] == "s" {
+		e["Exten"] = "1234567MYDID"
+	}
	
	if /*_, ok := IncomingContext[e["Context"]]; !ok || */ e["Exten"] == "s" { // TODO: review this 's'!
		return
	}

You can also specify both from-pstn and from-pstn-toheader contexts in the config.

dialplan:
  incoming_context:
  - from-pstn
  - from-pstn-toheader
  outgoing_context:
  - macro-dialout-trunk
  - trunk-dial-with-exten
  ext_context:
  - macro-dial-one
  - macro-dial
  - dialOne-with-exten
  dial_context: from-internal

Is that trunk with registration ? If so, can you check if changing trunk's "Contact user" to your DID will ask the trunk provider to send calls to that extension and not "s" ?
image

@joshuaalayon
Copy link
Author

joshuaalayon commented Jan 1, 2025

Changing trunk's "Contact user" to DID made the call pop up in the log with timestamp and phone number in "Calls" section! No need to edit ami_connector.go. Is it possible to have calls show up in the browser or to be able to click to call back?

./asterlink
INFO[0000] AsterLink
INFO[0000] Setting log level fields.level=debug
INFO[0000] Using SuiteCRM Connector
INFO[0000] User list updated suite=true users="map[987:1]"
INFO[0000] Enabling web server addr="127.0.0.1:5678" suite=true
INFO[0000] Established connection with AMI fields.msg="Asterisk Call Manager/10.0.0"
DEBU[0036] New incoming call lid=1735715185.19
DEBU[0036] MixMonitor lid=1735715185.19 rec=2025/01/01/in-1**********-1**********-20250101-020625-1735715185.19.wav uid=1735715185.19
DEBU[0036] Call registred id=186d8a71-b3cb-4389-d65b-6774e9349e0f lid=1735715185.19 suite=true
DEBU[0108] Dial stop ext=987 lid=1735715185.19
DEBU[0108] Clear recording lid=1735715185.19 uid=1735715185.19
DEBU[0108] Call finished lid=1735715185.19

@serfreeman1337
Copy link
Owner

Check README_suitecrm.md.
For call card and click2call you need to configure "Endpoint URL" for SuiteCRM Module.
http://<asterlink connector server ip address>:<asterlink connector listen port>

@joshuaalayon
Copy link
Author

It is configured according to the example

suitecrm:
url: https://SuiteCRM base URL in https is the issue that this url is https?
endpoint_token: same token as Asterlink settings in SuiteCRM GUI
endpoint_addr: "127.0.0.1:5678"

http://127.0.0.1:5678 is address given in gui and endpoint token is same in both gui and conf.yml

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Jan 1, 2025

Is asterlink and suitecrm on the same server ? If so, enable proxy mode in gui.

Address given in gui will be used by both suitecrm and users browsers to connect to asterlink, so it must be accessible for them.

With current setup:

Without proxy mode enabled:
User's browser -> http://127.0.0.1:5678

With proxy mode enabled:
User's browser -> https://SuiteCRM -> http://127.0.0.1:5678

endpoint_addr in conf.yml is a listen address.

@joshuaalayon
Copy link
Author

proxy mode is enabled and I think working because calls are logging

ext= only shows up in Asterlink CLI after "Dial stop"
so the extension is only being passed, if I hang up the remote phone, calling into the pbx. If I answer the extension on a hard phone, the extension number is not passed, basically nothing passes the extension number to Asterlink CLI, until I hang up the phone that is calling into the pbx. not sure if that helps.

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Jan 1, 2025

Is your extension in from-internal context ?
Also note: there is no support for Follow-Me.

I will need AMI dump to debug this issue.

AMI dump can contain some private info, like CallerID and DID numbers
You can send it to my email.

  • Run:
    ami-dump.zip
    ./ami-dump -c ami_host:5038 -u ami_user -p ami_pass | tee -i dump.txt
  • Answer a call and hangup.
  • AMI events will be in the dump.txt file.

@joshuaalayon
Copy link
Author

I emailed you it. Big file!

@serfreeman1337
Copy link
Owner

For ring groups you need to also add dial-with-exten to ext_context:

dialplan:
  incoming_context:
  - from-pstn
  - from-pstn-toheader
  outgoing_context:
  - macro-dialout-trunk
  - trunk-dial-with-exten
  ext_context:
  - macro-dial-one
  - macro-dial
  - dialOne-with-exten
  - dial-with-exten
  dial_context: from-internal

@joshuaalayon
Copy link
Author

joshuaalayon commented Jan 2, 2025

Okay that made it much better. It now logs calls as soon as they come in, in the "Calls" GUI of SuiteCRM, not after they are hung up, and they are also assigned to the correct user. Asterlink also now reports "Answer" when the physical phone is answered, and the duration of the call is recorded in the "Calls" GUI of SuiteCRM. It also recognizes the extension both as soon as the user exits the IVR and as soon as the call is hung up, it sees the extension number both times.

With "- from-pstn-toheader" in the incoming_context, it does not seem to record the extension number, even if "- from-pstn" is also there. But it records the extension number fine with only "- from-pstn" along with the number in the Contact User in FreePBX GUI.

However, there is still no click to call or popup when the call comes in. I'm wondering if I'm missing something, a module or something for this. I have the endpoint URL configured as well as the proxy enabled.

@serfreeman1337
Copy link
Owner

However, there is still no click to call or popup when the call comes in. I'm wondering if I'm missing something, a module or something for this. I have the endpoint URL configured as well as the proxy enabled.

If your endpoint url settings is correct, you should see "connected" messages in asterlink logs when you open suitecrm pages.

Are both suitecrm and asterlink on the same server machine ?

You can access https://SuiteCRM/index.php?entryPoint=AsterLink&action=stream URL in your browser trigger this connection manually. Asterlink should print the "connected" message.

Also, if you click on the contact phone in suitecrm, it shows you "Unable to dial" popup ?

from-pstn-toheader

If contact user works, you can set from-pstn context for the trunk on freepbx.

@joshuaalayon
Copy link
Author

Yes, they are running on the same machine. There is no response from https://SuiteCRM/index.php?entryPoint=AsterLink&action=stream unless I set the url to localhost or 127.0.0.1 or the machines remote IP, at which point it says "Extension not found for user id". Asterlink also responds with "ERRO[0000] invalid character '<' looking for beginning of value suite=true" when starting this way even though it does continue to run.

Should I try disabling HTTPS? Is that the issue?

@serfreeman1337
Copy link
Owner

HTTPS shouldn't be an issue.

You can check if your suitecrm has connection with asterlink by running tcpdump on its server.
tcpdump -A -p -ni lo port 5678

It should look like this:
Screenshot_20250102_121354

Also, suitecrm webserver needs php-curl module installed.

@yeu0thibao
Copy link

yeu0thibao commented Jan 2, 2025

is there any way to use asterlink 0.5.1 with suitecrm version 8.7? i tried to install but it says copy error

@joshuaalayon
Copy link
Author

joshuaalayon commented Jan 2, 2025

I don't think so - I had to delete SuiteCRM and reinstall as 8.5:
wget https://github.com/salesagility/SuiteCRM-Core/releases/download/v8.5.0/SuiteCRM-8.5.0.zip

at which point the module loaded right up in module loader, no copy() error

@serfreeman1337
Copy link
Owner

serfreeman1337 commented Jan 2, 2025

is there any way to use asterlink 0.5.1 with suitecrm version 8.7? i tried to install but it says copy error

You should've created a new issue. Well, whatever.

8.7 has a bug where copy is no longer allowed as an array key in the manifest.php file.
Problem commit: salesagility/SuiteCRM@e572230

Here is the archive with workaround:
suitecrm-asterlink-module-87uploadfix.zip

Asterlink 0.5.1 still works with 8.7.1.

@yeu0thibao
Copy link

is there any way to use asterlink 0.5.1 with suitecrm version 8.7? i tried to install but it says copy error

You should've created a new issue. Well, whatever.

8.7 has a bug where copy is no longer allowed as an array key in the manifest.php file. Problem commit: salesagility/SuiteCRM@e572230

Here is the archive with workaround: suitecrm-asterlink-module-87uploadfix.zip

Asterlink 0.5.1 still works with 8.7.1.

sorry , i will create issues next time , i will try with fix module , thanks a lot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants