Contact Sales

All fields are required

Store Information Securely During Calls with AI Agents | 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

Daniele Zils

This tutorial shows how to store and reuse per-call information with SignalWire AI Agent by using the set_meta_data action in SignalWire Markup Language (SWML). It walks through a Node.js server that returns structured webhook responses, stores personalized values in metadata, and reuses the same meta_data_token across functions so later steps can access the stored data, including sending a personalized Short Message Service (SMS) booking link without exposing sensitive information to the language model.

Use Meta Data to Store Information Securely with SignalWire AI

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 Discord.

Frequently asked questions

What is set_meta_data in SignalWire Markup Language (SWML)?

set_meta_data is a SignalWire Markup Language (SWML) action that stores values in call-scoped metadata during a live session so the workflow can reuse them later without passing them through the language model.

What is a meta_data_token, and why is it used?

A meta_data_token lets multiple functions in the same call session access the same stored metadata, which makes it possible to store information once and reuse it across steps in the workflow.

When should you store data as metadata instead of giving it to the model?

Store data as metadata when it is sensitive, operational, or should not be exposed to the model, for example booking links, identifiers, computed results, or customer details used to complete a workflow step.

How do you use stored metadata to send a personalized SMS during a call?

Store the personalized message or link in metadata, then have the SMS-sending function read it using the same meta_data_token so the outbound Short Message Service (SMS) content matches the caller’s session and preferences.

What makes webhook responses easier for an AI agent to use reliably?

Return a predictable, structured response so the agent can store the right fields, trigger the next function immediately when needed, and avoid ambiguity during multi-step workflows.

Related Articles