Fetch Data from Your Platform
Fetch external data in real time.
With Callr Actions, you can fetch external data in real time during a call using the fetch@v2
action. This allows you to personalize the experience based on CRM records, user profiles, preferences, or anything else your backend can return.
⚙️ How It Works
Here’s a typical flow:
- The call is ringing, but not yet answered (
autoAnswer: false
) - While the caller waits, the scenario fetches data using
fetch@v2
- The response is decoded (if JSON), and stored in a variable
- Once data is available, the call is answered and personalized logic runs
- After hangup, a second
fetch@v2
can be used to push data back to your system
This keeps your call experience dynamic and up-to-date — without writing a single line of server-side telephony logic.
🧪 Example: Fetch User Profile During a Call
This scenario fetches information about the caller using their number, greets them personally, and pushes data to your backend after the call.
description: Fetch & Push
variables:
$user: undefined
defaults:
language: en-GB
autoAnswer: false
branches:
inbound-call:
actions:
- action: ringing@v1
- action: fetch@v2
params:
audio:
enabled: false
url: https://randomuser.me/api
timeout: 4
result: $api
- action: answer@v1
- if: "!$api.ok || !$api?.json?.results?.length"
then:
- action: say@v2
params:
what: I am sorry, I have no information about you. Try again later.
- action: hangup@v1
- action: javascript@v1
params:
code: $user = $api.json.results[0]
- action: say@v2
params:
what: Hello ${{ $user.name.title }} ${{ $user.name.first }} ${{ $user.name.last }}!
- action: say@v2
params:
what: My file says you live in ${{ $user.location.city }}, ${{ $user.location.country }}.
- action: say@v2
params:
what: See you another time!
hangup:
actions:
- action: fetch@v2
params:
url: https://your-server.com/call-logs
method: POST
headers:
Content-Type: application/json
Authorization: Bearer <token>
body: |
{
"call": ${{ JSON.stringify(call) }},
"user": ${{ JSON.stringify($user) }}
}
You can replace
https://randomuser.me/api
with your actual backend URL, using the caller’s number as a query parameter to look up user data.
🔍 Example: Fetch Contact from Salesforce
Using Callr’s Salesforce OAuth Integration, you can search Salesforce records during a call and use them in real time.
- action: javascript@v1
params:
code: >
return "FIND {\\${{ call.fromNumber }}} IN PHONE FIELDS
RETURNING Contact(Id,Name), Lead(Id,Name), Account(Id,Name) LIMIT 10"
result: $query
- action: fetch@v2
params:
headers:
Authorization: Bearer ${{ integrations.defaults.salesforce.accessToken }}
url: ${{ integrations.defaults.salesforce.metadata.instance_url }}/services/data/v61.0/search/?q=${{ encodeURIComponent($query) }}
result: $result
- if: $result?.json?.searchRecords?.length > 0
action: javascript@v1
params:
code: $caller = $result.json.searchRecords[0]
Now $caller
contains the first matching Salesforce record — and can be used to tailor the call logic.
📥 Tips for Fetching
- Use
audio.enabled: false
if the call is still ringing — this prevents interruptions - Handle timeouts and failed requests gracefully with fallback messages
- Use
javascript@v1
to reshape or extract values from the JSON response - Chain fetch to first retrieve data and later log results
🧠 Use Cases
- 🔎 Lookup CRM or user profile data before answering
- 💬 Greet the caller by name or location
- 🛒 Fetch order status, appointment time, or preferences
- 📤 Push call results, CDRs, or input back to your platform
Want to test locally? Use ngrok to expose your local server to the internet while developing.
Updated 15 days ago