Task

Create a user, connect a SIP gateway and initiate an outgoing call using the REST API

Creating a Webitel user

We need to create a new user in Webitel that will make calls using the REST API: http://api.webitel.com/en/latest/restful-http-api-accounts.html#creat-an-account

After creating a user, he must connect a SIP phone or Webitel Verto Phone with his own parameters.

Create SIP gateway for calls

Create a new SIP gateway, as specified in SIP Gateway Management.

Routing

In the current example, we will create an outbound routing scheme for all dialed numbers through the SIP gateway created above. To do this, in the section 08 Callflow is necessary to add outgoing rules, following the example in the article (Create outbound route) or send via REST API:

POST /api/v2/routes/default
X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6ImNmMTQ3ZTFiLTk1ZGYtNDI1OC05ZT
M2LWQ4NWZkZDZlZDUzZiIsImV4cCI6MTQ5NzkwNjAwMDAwMCwiZCI6InNpdGUiLCJ0IjoiZG9tYWluIiwidiI6Mn0.o
-bcG_U3oJMN4r3YaBfSg9CcrZPANZulcapR4E6TSdg
BODY
 [
      {
          "destination_number": "^(.*)$",
          "name": "My outbound route",
          "order": 0,
          "disabled": false,
          "domain": "test.webitel.com",
          "fs_timezone": null,
          "callflow": [
    {
        "ringback": {
            "call": {
                "name": "$${ru-ring}",
                "type": "tone"
            },
            "transfer": {
                "name": "$${ru-ring}",
                "type": "tone"
            }
        }
    },
    {
        "recordSession": {
            "action": "start",
            "type": "mp3",
            "stereo": "false"
        }
    },
    {
        "bridge": {
            "endpoints": [
                {
                    "name": "myGWName",
                    "type": "sipGateway",
                    "dialString": "&reg0.$1"
                }
            ]
        }
    }
          ],
          "version": 2
      }
  ]

The number will be transmitted to our gateway myGWName without any changes.

Call initiation

To initiate a call between the Webitel user and the external phone number, you need to run the REST API: http://api.webitel.com/en/latest/restful-http-api-channels.html#originating-a-new-call

POST /api/v2/channels
Content-Type: application/json
X-Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6ImNmMTQ3ZTFiLTk1ZGYtNDI1OC05ZT
M2LWQ4NWZkZDZlZDUzZiIsImV4cCI6MTQ5NzkwNjAwMDAwMCwiZCI6InNpdGUiLCJ0IjoiZG9tYWluIiwidiI6Mn0.o
-bcG_U3oJMN4r3YaBfSg9CcrZPANZulcapR4E6TSdg
  {
      "calledId":"79091234567",
      "callerId": "201@test.webitel.com",
      "auto_answer_param": "sip_h_Call-Info=answer-after=0"
  }

calledId - number on wich to call

callerId - to which webitel user connect

LIMITATION

At the moment, there is no API in the Webitel to connect two external numbers without the participation of the Webitel user.

  • No labels