Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# make a phone call to a given number, play a message and hangup.
# export CTM_API_KEY, CTM_API_SECRET and CTM_ENDPOINT you can get them from either /accounts/edit or /agencies/{id}/edit pages
# export CTM_ACCOUNT_ID=your account id
read -r -d '' request_body << request-json-body
{
"call_number": "${TO_NUMBER}",
"from_number": "${FROM_NUMBER}",
"route": "hangup",
#!/bin/bash
# using ctm forms api to manage creation, updates and destruction of forms
# as well as submitting data to the forms
# external to this script you should
# export CTM_API_KEY, CTM_API_SECRET and CTM_ENDPOINT you can get them from either /accounts/edit or /agencies/{id}/edit pages
# export CTM_ACCOUNT_ID=your account id
# form options include:
<< 'fields-avialable'
@taf2
taf2 / Gemfile
Created June 13, 2022 13:24
Here's a gist showing what breaks when running the examples for ruby torchtext
source 'https://rubygems.org'
gem "torchtext"
<html>
<head>
<script async src="https://app.calltrackingmetrics.com/assets/ctm-phone-a4abb987e3ee84eea639cab343e2bfd5.js"></script>
</head>
<body>
<ctm-phone></ctm-phone>
</body>
</html>
import os
import sys
import re
import websocket
import http.client as httplib
import base64
import json
import urllib
import requests
from requests.auth import HTTPBasicAuth
exports.handler = async function(event, context, callback) {
// https://api.calltrackingmetrics.com/api/v1/accounts/{{account_id}}/calls/{{id}}/tag?tag={{tag}}
const source_tag = event.activity.source_tag;
console.log("check for tag: ", source_tag);
if (source_tag && source_tag.length) {
console.log("apply source tag: ", source_tag)
await context.ctm.api_patch(`calls/${event.activity.id}/tag`, {"tag":source_tag});
context.done();
} else {
console.log("no source tag")
@taf2
taf2 / action.js
Last active April 15, 2022 18:13
Lead Form Process data from Google Ads Lead Form Extensions
/*
{"lead_id":"TeSter-123-ABCDEFGHIJKLMNOPQRSTUVWXYZ-abcdefghijklmnopqrstuvwxyz-0123456789-AaBbCcDdEeFfGgHhIiJjKkLl",
"user_column_data":[{"column_name":"Full Name","string_value":"FirstName LastName","column_id":"FULL_NAME"},
{"column_name":"User Phone","string_value":"+16505550123","column_id":"PHONE_NUMBER"},
{"column_name":"User Email","string_value":"[email protected]","column_id":"EMAIL"},
{"column_name":"Company Name","string_value":"CompanyName","column_id":"COMPANY_NAME"}],
"api_version":"1.0","form_id":40000000000,"campaign_id":281489216452814,
"google_key":"----","is_test":true,
"gcl_id":"TeSter-123-ABCDEFGHIJKLMNOPQRSTUVWXYZ-abcdefghijklmnopqrstuvwxyz-0123456789-AaBbCcDdEeFfGgHhIiJjKkLl",
"adgroup_id":20000000000,"creative_id":30000000000}
from hashlib import sha1;
import hmac;
import base64;
timestamp = '1350310273' # X-CTM-Time header
signature = 'A sample signature from CTM=' # X-CTM-Signature header
api_secret_key = 'your-api-key' # your secret key can be found in the account settings
msg = '{...}' # request body
mac = hmac.new(api_secret_key, timestamp, sha1)
mac.update(msg)
// wrapper around the customers ctm_action.js
const HTTPS = require('https');
const URL = require('url');
function http_request(opts, requestBodyCallback) {
let promise = new Promise(function(resolve, reject) {
let request = HTTPS.request(opts, function(response) {
let data = "";
response.on('data', function (chunk) { data += chunk; });
response.on('end', function () { resolve({request: request, response: response, responseBody: data}); });