Embedding the Webphone
Embedding the webphone into your website
If your website is hosted on the Wordpress CMS, go directly to this section: WordPress plugin
Including the webphone JavaScript code to your index.html
Copy all the .js files inside the /static/js folder to your web server. You can see a template of the index.html file in demo/templates/index.html to know what you need to modify in your page if you want to add the WebPhone. Anyway, let's describe what to do:
Include all .js files in your page's html, as seen in the index.html of the demo.
Important
Keep the order of the .js files as shown below.
Include the following block, where the JavaScript module context is located. Below is the explanation of the variables:
Changing the content of the WebPhone html
Take a look at the phoneJstemplate.js file inside demo/static/js/. This file defines a variable that will render/generate the html content of the webphone. This is made possible by a JavaScript library called mustache.
You can change the HTML template to your liking but you cannot modify the mustache variables, which are defined like this: {{{{webphone_keys_id}}}}
Obtaining SIP login credentials through the OMniLeads API
The username and password entered for the Webphone Client User are used to obtain the SIP credentials, in order to log in to the phone system within OMniLeads. OMniLeads provides an API to obtain these credentials, which will then be used by the WebPhone. To obtain them, you have to make a POST request to this URL: “https://OML_HOST/api/v1/webphone/credentials/” using a Basic Authentication Scheme.
Note
The SIP credentials provided by the API are ephemeral. They become obsolete after the time set by the WEBPHONE_CLIENT_TTL variable. The credentials are refreshed every time the API is queried, and this happens every time a client makes a call from the webphone. The default is set to 20 minutes because we consider that an average call lasts that long, but if in your business some calls last longer, consider increasing the value of this variable. This is an example of a request to the API URL using Postman. It is just to show the API response:
You can see an example of the python code to connect to the API and get the credentials in this file: demo/views.py
Changing the design of the webphone
The DOM for this application is as follows:
With this DOM you can set any IDs and classes you want, and you can use them in your .css file to change the default layout that the webphone brings.