MikoPBX development
  • MikoPBX development guide
  • Prepare IDE and system tools
    • Windows
    • Linux
    • Mac
  • Modules developement
    • How to start
    • Data model
    • Module installer class
    • Module main class
    • Module interface
    • Translations(empty)
    • Debuging
      • Configuring IDE
      • Debug PHP-AGI
      • Debug PHP Worker
      • Debug PHP Script
      • Debugging behind NAT
  • Internal structure
  • Admin interface(empty)
  • API
    • REST API
    • AMI / AJAM
    • AGI
  • Core(empty)
  • Marketplace
    • Licensing (empty)
  • Cookbook
    • Forms
      • Create module form
      • Create datatable
      • Add field into existing form
    • Asterisk
      • Hook on incoming call
      • Interact with AMI
      • Modify extensions.conf
    • Rights and auth
      • External authentication
      • Limited rights
Powered by GitBook
On this page
  • Originate
  • Redirect
  • Attended transfer

Was this helpful?

Edit on GitHub
  1. API

AMI / AJAM

Originate

Connect to the PBX via ssh. Run the command to connect to the AMI:

busybox telnet 127.0.0.1 5038 

Perform authorization:

Action: Login
Username: phpagi
Secret: phpagi
Events: off

Perform Originate to call from 201 to 203:

Action: Originate
Channel: Local/201@internal-originate
Context: all_peers
Exten: 203
Priority: 1
Callerid: 201
Variable: SIPADDHEADER="Call-Info:\;answer-after=0",pt1c_cid=203,ALLOW_MULTY_ANSWER=1
  • SIPADDHEADER - The header will be added to the INVITE for the internal number 201

  • pt1c_cid - destination number

  • ALLOW_MULTY_ANSWER - If there are multiple registrations on account 201, SIPADDHEADER will be sent to all contacts

Connect to the PBX via ssh. Run the command to connect to the AMI:

h='127.0.0.1';
u='phpagi';
p='phpagi';
port='8088';

from='201';
to='203';

# Login
tcookie="$(curl -I "http://${h}:${port}/asterisk/rawman?action=login&username=${u}&secret=${p}" | grep Cookie | awk -F': ' '{ print$2 }')";

# Send Originate command to call from ${from} to ${to}
curl --cookie "${tcookie}" "http://${h}:8088/asterisk/rawman?action=originate&channel=Local/${from}@internal-originate&exten=${to}&context=all_peers&priority=1&callerid=${from}&Variable=pt1c_cid=${to},SIPADDHEADER="Call-Info:\;answer-after=0"&ALLOW_MULTY_ANSWER=1";

Make new file

touch /tmp/originate.call;

Add command to file (call from 201 to 203):

Channel: Local/201@internal-originate
Context: all_peers
Extension:203
Priority: 1
Callerid: 201
Archive: yes

Setvar: SIPADDHEADER=Call-Info:\;answer-after=0
Setvar: pt1c_cid=203
Setvar: ALLOW_MULTY_ANSWER=1

Move file to asterisk spool dir:

mv /tmp/originate.call /storage/usbdisk1/mikopbx/astspool/outgoing

Redirect

Forwarding without consultation

Action: Redirect
Channel: PJSIP/201-000001
Context: internal-transfer
Exten: 203
Priority: 1
  • "PJSIP/201-000001" - Channel for forwarding

  • "internal-transfer" - For all redirects, use only this context

  • "203" - destination number

  • The channel that was in bridge with PJSIP/201-000001 will be completed

Attended transfer

Call forwarding with consultation

Action: Atxfer
Channel: PJSIP/201-000001
Context: internal-transfer
Exten: 203
Priority: 1
  • "PJSIP/201-000001" - The channel that transfers the call it will be connected to the number 203 for consultation

  • "internal-transfer" - For all redirects, use only this context

  • "203" - destination number

  • When the PJSIP/201-000001 channel is completed, the bridge channel will be connected to 203

PreviousREST APINextAGI

Last updated 3 years ago

Was this helpful?