Configuring Botstream Dial Plan

1. Adding an Extension to the Botstream Dial Plan


The configuration for the Botstream dial plan is stored in default.xml, located in the /usr/local/freeswitch/conf/dialplan/ directory.

To configure the Botstream dial plan, you need to create extensions for each destination number in default.xml. Below is an example of an extension configured for the destination number 6600:

<!-- Botsream agent assist test -->
<extension name="botsream_agent_assist">
  <condition field="destination_number" expression="^6600$">
    <action application="answer"/>
    <action application="set" data="tenant_id=<your-tenant-id>"/>
    <action application="set" data="call_params=eyJjYWxsX3R5cGUiOiAiY3VzdG9tZXIifQ=="/>
    <action application="bot-in-streamer"/>
  </condition>
</extension>

To create a new destination number, add a new extension. Replace the expression value (condition tag) with your desired destination number.


2. Preparing the call_params JSON

The call_params value is a Base64-encoded JSON string that contains configuration details.

Below is a sample call_params JSON structure with the required parameters

{
    "call_type": "customer",
    "websocket_host":"<websocket-host-ip-address>",
    "websocket_port": 7254,
    "websocket_app": "/",
    "datacollection": <url-to-client-http-host>,
    "token": <bearer-token>,
    "chunk_size":16000,

    "bot_inactivity_limit":0

}

If the websocket server details are present in the call_params, botstream will automatically connect to the websocket server mentioned and stream the call audio in realtime.
If the datacollection url and bearer token are present in call_params, botstream will automatically submit the call CDR in JSON format as a HTTP POST request to the url.

Steps to Encode the JSON String:

You can use the base64 library in Python to encode a JSON string.

To Encode run:

echo <call-params-json-string>|python3 -m base64 -e

Example: 

echo '{"campaign":"Test"}'|python3 -m base64 -e


Verify by Decoding:

echo <encoded-string>|python3 -m base64 -d

Example:

echo 'eyJjYW1wYWlnbiI6IlRlc3QifQo='|python3 -m base64 -d


3. Updating the Dial Plan

Once you have updated the call_params, reload the XML values by running the following command:

fs_cli -x "reloadxml"

This command will enable Botstream to reload the XML configuration and apply the updated settings.