((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/twilio" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "twilio" (p "Bindings to the Twilio API") (toc) (section 3 "Abstract" (p (link "http://www.twilio.com/" "Twilio") " allows one to send SMSes and place calls using their API; and the " (tt "twilio") " egg requires at least three pieces of information to do so:") (ul (li "The account SID") (li "The auth token") (li "The from number")) (p "They are populated initially from the environment variables " (tt "TWILIO_SID") ", " (tt "TWILIO_AUTH") ", " (tt "TWILIO_FROM") "; respectively. It is also possible to set the dynamic parameters " (tt "twilio-sid") ", " (tt "twilio-auth") ", " (tt "twilio-from") ".")) (section 3 "Documentation" (section 4 (tt "twilio-sid") (def (sig (parameter "twilio-sid → (get-environment-variable TWILIO_SID)" (id twilio-sid))) (p "The Twilio account SID") (highlight scheme "(define twilio-sid (make-parameter (get-environment-variable \"TWILIO_SID\")))"))) (section 4 (tt "twilio-auth") (def (sig (parameter "twilio-auth → (get-environment-variable TWILIO_AUTH)" (id twilio-auth))) (p "The Twilio auth token") (highlight scheme "(define twilio-auth (make-parameter (get-environment-variable \"TWILIO_AUTH\")))"))) (section 4 (tt "twilio-from") (def (sig (parameter "twilio-from → (get-environment-variable TWILIO_FROM)" (id twilio-from))) (p "The phone number from which to post") (highlight scheme "(define twilio-from (make-parameter (get-environment-variable \"TWILIO_FROM\")))"))) (section 4 (tt "twilio-url") (def (sig (parameter "twilio-url → https://~a:~a@api.twilio.com/2010-04-01/Accounts/~a/~a" (id twilio-url))) (p "The Twilio API URL") (highlight scheme "(define twilio-url\n  (make-parameter \"https://~a:~a@api.twilio.com/2010-04-01/Accounts/~a/~a\"))"))) (section 4 (tt "twilio-make-call") (def (sig (procedure "(twilio-make-call to #!key url application-sid method fallback-url fallback-method status-callback status-callback-method send-digits if-machine timeout record) → unspecified" (id twilio-make-call))) (p "Make a call using the Twilio API; see " (link "http://www.twilio.com/docs/api/rest/making-calls") ".") (dl (dt (tt "to")) (dd "The phone number to call") (dt (tt "url")) (dd "TwiML URL when the call connects") (dt (tt "application-sid")) (dd "Alternatively, the app containing the URL") (dt (tt "method")) (dd "Method to request " (tt "url")) (dt (tt "fallback-url")) (dd "Second " (tt "url") " to try") (dt (tt "fallback-method")) (dd "Method to which to fall back") (dt (tt "status-callback")) (dd "URL to post status to") (dt (tt "status-callback-method")) (dd "Method to use") (dt (tt "send-digits")) (dd "Keys to dial after connecting") (dt (tt "if-machine")) (dd "Determine whether the caller is a machine") (dt (tt "timeout")) (dd "How long to let the phone ring") (dt (tt "record")) (dd "Whether to record the call")) (highlight scheme "(define (twilio-make-call\n         to\n         #!key\n         url\n         application-sid\n         method\n         fallback-url\n         fallback-method\n         status-callback\n         status-callback-method\n         send-digits\n         if-machine\n         timeout\n         record)\n  (let ((parameters\n          `((from unquote (twilio-from))\n            (to unquote to)\n            (url unquote url)\n            (application-sid unquote application-sid)\n            (method unquote method)\n            (fallback-url unquote fallback-url)\n            (fallback-method unquote fallback-method)\n            (status-callback unquote status-callback)\n            (status-callback-method unquote status-callback-method)\n            (send-digits unquote send-digits)\n            (if-machine unquote if-machine)\n            (timeout unquote timeout)\n            (record unquote record))))\n    (with-input-from-request\n      (twilio-url-calls)\n      (upper-camel-filter-parameters parameters)\n      void)))")) (section 5 "Examples" (p "Placing a call") (pre "(twilio-make-call \"+14158141829\" url: \"http://example.com/twiml.scm\")"))) (section 4 (tt "twilio-send-sms") (def (sig (procedure "(twilio-send-sms to body #!key status-callback application-sid) → unspecified" (id twilio-send-sms))) (p "Send an SMS using the Twilio API; see " (link "http://www.twilio.com/docs/api/rest/sending-sms") ".") (dl (dt (tt "to")) (dd "The number to send to") (dt (tt "body")) (dd "The SMS to send") (dt (tt "status-callback")) (dd "POST when the message is processed") (dt (tt "application-sid")) (dd "The application's SID")) (highlight scheme "(define (twilio-send-sms to body #!key status-callback application-sid)\n  (let ((parameters\n          `((from unquote (twilio-from))\n            (to unquote to)\n            (body unquote body)\n            (status-callback unquote status-callback)\n            (application-sid unquote application-sid))))\n    (with-input-from-request\n      (twilio-url-sms)\n      (upper-camel-filter-parameters parameters)\n      void)))")) (section 5 "Examples" (p "Sending an SMS") (pre "(twilio-send-sms \"+14158141829\"\n                 \"If you wish to make an apple pie from scratch, you must first invent the universe.\")"))) (section 4 (tt "twilio-write") (def (sig (procedure "(twilio-write response) → unspecified" (id twilio-write))) (p "Write STwiML as TwiML.") (dl (dt (tt "response")) (dd "The STwiML response")) (highlight scheme "(define twilio-write write-shtml-as-html)"))) (section 4 (tt "twilio-response") (def (sig (procedure "(twilio-response . verbs) → STwiML" (id twilio-response))) (p "Wrap verbs in a STwiML response; see " (link "http://www.twilio.com/docs/api/twiml") ".") (dl (dt (tt "verbs")) (dd "The verbs to wrap in a response")) (highlight scheme "(define (twilio-response . verbs) `(Response ,@verbs))"))) (section 4 (tt "twilio-say") (def (sig (procedure "(twilio-say text #!key voice loop language) → STwiML" (id twilio-say))) (p "Say something; see " (link "http://www.twilio.com/docs/api/twiml/say") ".") (dl (dt (tt "text")) (dd "The text to say") (dt (tt "voice")) (dd "The voice to say it in") (dt (tt "loop")) (dd "How many times to say it") (dt (tt "language")) (dd "The language to say it in")) (highlight scheme "(define (twilio-say text #!key voice loop language)\n  (let ((parameters\n          (lower-camel-filter-parameters\n            `((voice ,voice) (loop ,loop) (language ,language)))))\n    (if (null? parameters)\n      `(Say ,text)\n      `(Say (,(string->symbol \"@\")\n             ,@(lower-camel-filter-parameters parameters))\n            ,text))))"))) (section 4 (tt "twilio-play") (def (sig (procedure "(twilio-play url #!key loop) → STwiML" (id twilio-play))) (p "Play something; see " (link "http://www.twilio.com/docs/api/twiml/play") ".") (dl (dt (tt "url")) (dd "The audio file to play") (dt (tt "loop")) (dd "How many times to play it")) (highlight scheme "(define (twilio-play url #!key loop)\n  (let ((parameters (lower-camel-filter-parameters `((loop ,loop)))))\n    (if (null? parameters)\n      `(Play ,url)\n      `(Play (,(string->symbol \"@\")\n              ,@(lower-camel-filter-parameters parameters))\n             ,url))))"))) (section 4 (tt "twilio-sms") (def (sig (procedure "(twilio-sms text #!key to from action method status-callback) → STwiML" (id twilio-sms))) (p "Send an SMS; see " (link "http://www.twilio.com/docs/api/twiml/sms") ".") (dl (dt (tt "text")) (dd "The text to send") (dt (tt "to")) (dd "The number to send it to") (dt (tt "from")) (dd "The number to send it from") (dt (tt "action")) (dd "Action URL") (dt (tt "method")) (dd (tt "POST") " or " (tt "GET") " for " (tt "action")) (dt (tt "status-callback")) (dd "Status callback URL")) (highlight scheme "(define (twilio-sms text #!key to from action method status-callback)\n  (let* ((parameters\n           (lower-camel-filter-parameters\n             `((to ,to)\n               (from ,from)\n               (action ,action)\n               (method ,method)\n               (status-callback ,status-callback)))))\n    (if (null? parameters)\n      `(Sms ,text)\n      `(Sms (,at ,@(lower-camel-filter-parameters parameters)) ,text))))")))) (section 3 "About this egg" (section 4 "Author" (p (int-link "/users/klutometis" "Peter Danenberg"))) (section 4 "Repository" (p (link "https://github.com/klutometis/twilio"))) (section 4 "License" (p "BSD")) (section 4 "Dependencies" (ul (li (int-link "hahn")) (li (int-link "htmlprag")) (li (int-link "http-client")) (li (int-link "matchable")) (li (int-link "s")) (li (int-link "setup-helper")))) (section 4 "Versions" (dl (dt (link "https://github.com/klutometis/twilio/releases/tag/0.1" "0.1")) (dd "First release: calls and SMS") (dt (link "https://github.com/klutometis/twilio/releases/tag/0.2" "0.2")) (dd "Some Twilio verbs") (dt (link "https://github.com/klutometis/twilio/releases/tag/0.2.1" "0.2.1")) (dd "Accomodate no parameters.") (dt (link "https://github.com/klutometis/twilio/releases/tag/0.2.2" "0.2.2")) (dd "Remove the dependency on setup-helper-cock.") (dt (link "https://github.com/klutometis/twilio/releases/tag/0.2.3" "0.2.3")) (dd "Remove dependency on debug.") (dt (link "https://github.com/klutometis/twilio/releases/tag/0.2.4" "0.2.4")) (dd "Add cock.") (dt (link "https://github.com/klutometis/twilio/releases/tag/0.2.5" "0.2.5")) (dd "Use hahn."))) (section 4 "Colophon" (p "Documented by " (int-link "/egg/hahn" "hahn") ".")))))