Contact Sales

All fields are required

Store Information Securely During Calls with AI Agents | SignalWireAdvanced communications from the source. | SignalWire
Developers

Store Information Securely During Calls with AI Agents

Utilizing set_meta_data to store information during a call with SignalWire's AI Agent

Technical Success Manager

Daniele Zils

SignalWire's AI Agent provides a dynamic and flexible solution for creating personalized autonomous workflows. By leveraging SignalWire Markup Language (SWML) and the set_meta_data action, you can enhance user interactions and manage information across functions using the same meta_data_token, without exposing the information to the language model.

This post will show you how to use set_meta_data to store user information in the meta_data temporarily during a call session, allowing for real-time access and personalization. Specifically, we'll demonstrate how an AI agent can assist visitors of an amusement park in selecting the best ride options and ticket packages based on their preferences. You can also follow along in the video demo below.


Setting Up the Node.js Server

In this tutorial, we use Node.js for the code snippets, employing Express and Body-Parser to build a streamlined and adaptable web application framework. This server will handle incoming requests and send instructions to our AI agent.

Note: If your IDE does not have port forwarding capabilities, consider using ngrok to tunnel your application and expose it to the internet securely.


This setup initializes Express, configures body-parser for JSON handling, and defines a route that sends instructions to the AI agent when a call is received. Finally, we listen on port 3000 to handle incoming requests.

Utilizing set_meta_data

The data_map object in the SWML script enables the ability to store and retrieve user information. First, the store_user_info function is defined with a specific purpose: to store visitor preferences for personalized offers. It takes two arguments: name and preferences.

Next, the data_map.webhooks.url object sends a GET request to the backend with the user's name and preferences as parameters.

Setting the Metadata

In the webhook's output section, the set_meta_data action stores the returned data in the meta_data object. The key is the user's name, and the value is the dynamically generated message (stored in ${Records[0].secret}).


Additional Actions

  • back_to_back_functions: true ensures that the next function is executed immediately after storing the metadata.

  • toggle_functions activates the send_custom_sms function to send an SMS with the booking link.

Importance of Response Structure

The server's response is designed to be easily processed by the AI agent, ensuring that the dynamically generated information is stored correctly and can be accessed throughout the session.

Example Response


User_info endpoint

The server's response is structured to provide a clear and personalized message to the user. The user_info endpoint determines the appropriate ticket link based on user preferences. Here's the simple logic implemented:


Sending the Booking Link via SMS

Finally, we set up the send_sms function to send the booking link to the user via SMS using the same meta_data_token established in the store_user_info function.


The meta_data object stores the user's preferences and booking link information. We use the meta_data_token to access this stored data, ensuring that the SMS is sent to the caller with the appropriate personalized message. The full code example is available here.

By leveraging SignalWire's AI agent and the set_meta_data function, you can provide personalized experiences, and ensure efficient data management throughout the call session.

Need help as you get started with SignalWire AI Agent? Start building for free today by signing up for a SignalWire Space, exploring our developer documentation, and bringing your questions to our community on Slack or discord.

Related Articles