Skip to content
  • There are no suggestions because the search field is empty.

Using Regex to Capture and Reuse Conversation Data

Meta Description: Learn how to use Regex named capture groups in Taalk to extract information from live conversations or email replies, then use that data in webhooks or save it to the Call Session Context (CSC). 👍 For Developer and Pro Serv team.

Introduction

Regex lets you detect and extract specific information directly from a conversation or email reply. By using named capture groups, you can turn what someone says into a variable you can reuse in webhooks, payloads, or across plugins in the same session.


How Regex Capture Works

When the AI Agent or contact says a line that matches your Regex pattern, the captured data is stored in a variable under the _regex namespace.

Example:

  • Spoken line:

    “I got your email as john.doe@example.com. Is that correct?”

  • Regex pattern:

I got your email as (?<__person_email>[^\\s,]+@[^\\s,]+\\.[^\\s,]+)\\.\\s+Is that correct
  • Captured variable:

__person_email = "john.doe@example.com"

Saving Captured Data to the Call Session Context (CSC)

Captured values can be persisted for later use in the same session.

// Save captured email
<save __person_email as contact_email>

// Later in the session, use:
<contact_email>

Using Captured Data in a Webhook

You can reference captured values in the webhook URL or JSON body.

// URL example:
https://api.example.com/leads?email=<_regex.__person_email>

// Body example:
{
"email": "<_regex.__person_email>",
"source": "taalk"
}

This works the same way for webhook responses:

// Example API response
{ "first_name": "John" }
// Save the field
<save first_name as webhook_first_name>

// Reference later
<webhook_first_name>

If the response is a list:

{ "html": "[ { \"first_name\": \"John\" }, { \"first_name\": \"Ava\" } ]" }
// Save the first object’s first_name
<save 0.first_name as webhook_first_name>

End-to-End Example

  1. Agent says: “I got your email as john.doe@example.com. Is that correct?”

  2. Regex pattern captures the email → _regex.__person_email.

  3. On success, plugin saves it: <save __person_email as contact_email>.
  4. Webhook sends the email in JSON body.

  5. Later, another plugin uses <contact_email>.


Tips for Regex Setup

  • Use named capture groups like (?<groupName>pattern).

  • Avoid greedy .*; use specific patterns ([^\\s,]+ for email tokens).

  • Anchor phrases around expected wording to reduce false positives.

  • Always test before deploying — use Regex101 for validation and debugging.