Technical Success Manager
Nicholas AhrendtIn this installment of SignalWire in Seconds, follow along to decipher a hidden message using SignalWire’s AI Gateway (SWAIG). SWAIG simplifies the connection between your AI voice agent and backend systems, allowing the AI to easily perform actions by integrating with databases or CRM software.
Visit the official SIS Github repository to view the code examples in their entirety.
We’ll walk through how you can draft Fleming, an AI-powered digital employee, from three code segments: a RELAY v4 messaging application, a simple script written in SignalWire Markup Language (SWML), and a basic Node.js webserver. When combined, Fleming will be capable of retrieving, decoding, and decrypting sensitive information, encrypted with an Openssl AES-256-CBC cipher and hidden in a CSV file.
To see how Fleming works, check out the video walkthrough below.
RELAY v4 messaging application
Start by creating a short messaging application for receiving and responding to incoming SMS. The RELAY v4 Realtime SDK speeds up development of communication applications by integrating multiple telecom features into a single client architecture.
When accessing the Messaging namespace of the Realtime client, your application can listen for events like onMessageReceived. These events are triggered when an incoming SMS or MMS is received on a specified topic.
The application will collect sensitive information from end users and store the data in a CSV file that Secret AI Agent Fleming will use later on. Users will be asked to submit the code_name of their intended target, and the secret_message they wish to convey.
To aid in the decryption process, users must also provide the key and initialization vector (IV) they used to encrypt their message. The response body of each reply will be stored in the CSV document.
Fleming’s SWML script and decryption server
Programmable Unified Communications (PUC) helps define the interaction between Fleming’s SWML script and the decryption server, which together shape his advanced personality and ability to decrypt complex ciphers.
SWAIG allows SignalWire’s AI agents to call one function immediately after another. This makes it easy to pass important data from one function to the next, streamlining your SWML script and improving the performance of your AI agent.
Three main functions will define the virtual agent’s skill set: fetch, decode, and decrypt. With each successive step, Fleming will perform the function specified in the prompt’s instructions.
Fetching the classified information
The first step is to equip your AI Agent with the tools to retrieve the classifiedInfo stored in your CSV document. This is where the arguments come into play: an argument is a JSON object that defines the input for the function.
In this scenario, the argument Fleming aims to pass along is a code_name given by the caller. When directed, he will navigate to your server’s /fetch endpoint, identified by the webhook URL in the function’s data_map.
Once the classified info is collected, it is returned to the AI Agent’s knowledge via the response of the data map’s output. Here, an action object is included as well, informing the caller that their encrypted message has been successfully retrieved.
/fetch server endpoint
At this endpoint, the code_name is used to search the CSV document created earlier. The goal is to find a Base64 encoded secret message, along with the 256-bit key used to encrypt it, and the 16-byte iv used for encryption randomness.
Decoding the secret message
The decode SWAIG function works similarly to fetch, taking the secret_message retrieved from the server as its property. This process results in a decoded message, providing a crucial piece of the decryption puzzle.
The next big change in the process involves toggle_functions. This ensures that Fleming doesn’t jump from retrieving the classified info to decrypting it without first obtaining the decoded message. This step is critical because the decryption process on the server would fail without it.
Decrypting the decoded message
Fleming’s SWML script concludes in the third SWAIG function: decrypt. To reinforce the toggle_functions sequence, set the activity parameter to false.
Using the combined information gathered from the CSV file and affirmed by the caller, your digital employee will send the server’s decryption endpoint a payload including the decoded message, key, and IV. Following execution of the server’s decryption function, Fleming will ultimately receive a regular JavaScript expression containing the fully decrypted message, which he will then share with the caller.
Configuring your phone number
Before deploying Fleming’s SWML script and your RELAY v4 messaging application, associate them with a SignalWire phone number.
A resource may be assigned to an address alias, a phone number, or a SIP domain app by navigating to the Addresses tab within the resource itself. Resources are malleable, allowing assignment to multiple addresses. Further on in your development, these assignments can be reconfigured or removed at will.
Test data
Code Name: <Your-Choice> Secret Message: payIZgzSKI8xKL/TXzkEmznxbV5Bcca5ermVauarKkDXszqgjEtkKuszVdw3Vj/i Key: 9809dfbb2026dc5eba581451174db58d1a34a567ded81778f594e3c99215cd96 IV: 1082e827f6ba8e473ae05809e40a3580 Decrypted Message: Welcome to SignalWire in Seconds
Design your own digital employee from the ground up by exploring our developer docs for even more in-depth technical documentation and bring any questions to our developer community on Slack. We're excited to see what you build!