Skip to content

Instantly share code, notes, and snippets.

View jmadden's full-sized avatar
☘️

Jim Madden jmadden

☘️
View GitHub Profile
@jmadden
jmadden / 1-start.js
Last active July 19, 2023 22:31
Voice mail system using Twilio Functions
exports.handler = function(context, event, callback) {
let twiml = new Twilio.twiml.VoiceResponse();
const OWNER = '+1##########'; //Your mobile number.
if(event.From == OWNER){
const gather = twiml.gather({
action:'/callOut'
});
gather.say("Please enter the phone number you'd like to call followed by the pound sign.");
@jmadden
jmadden / forward_to_first_number.xml
Last active September 1, 2022 22:28
TwiML Incoming Calls - Forward call to numbers in order. Fire off VMail and send SMS on no answer
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<!-- Forward to first number and if no answer, action URL points to second number to try -->
<Dial timeout="15" action="forward_to_second_number.xml">
<Number url="whisper_instructions.xml">+15554441212</Number>
</Dial>
</Response>
@jmadden
jmadden / 1-outbound-call.php
Last active August 14, 2022 03:24
Twilio PHP Outbound Call and Gather Example
<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php
require_once '/path/to/vendor/autoload.php'; // Loads the library
use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "YOU_ACCOUNT_SID";
$token = "YOUR_AUTH_TOKEN";
$client = new Client($sid, $token);
@jmadden
jmadden / sequential_dialing.php
Last active April 6, 2022 03:02
Sequentially dial phone numbers using Twilio and Twilio's PHP helper library
<?php
// Require the bundled autoload file - the path may need to change
// based on where you downloaded and unzipped the SDK
require __DIR__ . '/twilio-php-master/Twilio/autoload.php';
// Use Twilio\TwiML to build TwiML instructions through PHP
use Twilio\Twiml;
// Instantiate a TwiML object.
$response = new Twiml();
@jmadden
jmadden / CustomListeners.js
Last active March 11, 2021 18:49
Location plugin-dual-channel-recording/src/listeners/CustomListeners.js
import { Actions, Manager, TaskHelper } from '@twilio/flex-ui';
import { getCustomerParticipant, getMyParticipant } from '../helpers';
const manager = Manager.getInstance();
const startCallRecording = async (callSid, callbackParameters) => {
console.debug('Creating recording for call SID:', callSid);
const fetchUrl = `https://${process.env.REACT_APP_SERVERLESS_DOMAIN}/recording/create`;
<?php
use Twilio\Twiml;
class TwimlWrap
{
/** @var TwilioTwiml */
protected $twiml;
public function __construct()
@jmadden
jmadden / record-status.php
Last active June 9, 2017 19:44
Send an SMS message through Twilio and record the message status to a log file using a Status Callback URL
<?php
$sid = $_REQUEST['MessageSid'];
$status = $_REQUEST['MessageStatus'];
$logfile = "status_callback_log.txt";
$log = fopen($logfile, 'a+');
fwrite($log, date('Y-m-d H:i:s')." SID = " . $sid . "\n");
fwrite($log, date('Y-m-d H:i:s')." Status = " . $status . "\n");
fwrite($log, "\n");
fclose($log);
<?php
// PHP Helper Library was dinstalled using Composer.
// Required if your envrionment does not handle autoloading
require __DIR__ . '/vendor/autoload.php';
// Use the REST API Client to make requests to the Twilio REST API
use Twilio\Rest\Client;
// Your Account SID and Auth Token from twilio.com/console

Ruby Basics – A Quick Reference Guide

Introduction

This document is meant to server as a jumping off point and reference guide for anyone that is new to programming in Ruby. This document will have some very basic concepts and may be useful for anyone needing a quick jog of the memory when first branching out(Git pun intended) into the brave new world of developing with Ruby. This document is not a complete review of Ruby and everything the language offers.

NOTE: If you are using this document you should have a rudimentary understanding of how to use terminal/commandline, irb and how to install Ruby Gems.

Working with variables

String interpolation vs. concatenation

In the following example we declare an age variable and then print it out to the screen in two different ways. The first way uses string interpolation, the second uses string concatenation.

age = 40

Rails Basics – A Quick Reference Guide

This document is meant to server as a jumping off point and reference guide for anyone that is new to programming in Rails. This document will have some very basic concepts and may be useful for anyone needing a quick jog of the memory when developing apps on Rails. This document is not a complete review of Rails and everything the framework offers.

NOTE: If you are using this document you should have a basic understanding of how to use terminal/commandline, irb and how to install Ruby Gems and Rails.

Table of Contents