Modules@robinpath/twilio
twilio

@robinpath/twilio

0.1.1Node.jsPublic

Twilio module for RobinPath.

Twilio

Twilio module for RobinPath.

Package: @robinpath/twilio | Category: Utility | Type: Utility

Authentication

twilio.setCredentials "your-credentials"

Call this once at the start of your script before using any other function. Credentials persist for the duration of the script execution.

Use Cases

Use the twilio module when you need to:

  • sendSms -- Use twilio.sendSms to perform this operation
  • sendMms -- Use twilio.sendMms to perform this operation
  • listMessages -- Use twilio.listMessages to perform this operation
  • getMessage -- Use twilio.getMessage to perform this operation
  • makeCall -- Use twilio.makeCall to perform this operation

Quick Reference

FunctionDescriptionReturns
setCredentialsConfigure twilio credentials.object
sendSmssendSmsobject
sendMmssendMmsobject
listMessageslistMessagesobject
getMessagegetMessageobject
makeCallmakeCallobject
listCallslistCallsobject
getCallgetCallobject
listPhoneNumberslistPhoneNumbersobject
lookupPhoneNumberlookupPhoneNumberobject
createVerifyServicecreateVerifyServiceobject
sendVerificationsendVerificationobject
checkVerificationcheckVerificationobject
listConversationslistConversationsobject
createConversationcreateConversationobject
addParticipantaddParticipantobject
sendConversationMessagesendConversationMessageobject
getAccountInfogetAccountInfoobject
deleteMessagedeleteMessageobject

Functions

setCredentials

Configure twilio credentials.

Module: twilio | Returns: object -- API response.

twilio.setCredentials
ParameterTypeRequiredDescription
accountSidstringYesaccountSid
authTokenstringYesauthToken

sendSms

sendSms

Module: twilio | Returns: object -- API response.

twilio.sendSms
ParameterTypeRequiredDescription
inputstringNoInput parameter

sendMms

sendMms

Module: twilio | Returns: object -- API response.

twilio.sendMms
ParameterTypeRequiredDescription
inputstringNoInput parameter

listMessages

listMessages

Module: twilio | Returns: object -- API response.

twilio.listMessages
ParameterTypeRequiredDescription
inputstringNoInput parameter

getMessage

getMessage

Module: twilio | Returns: object -- API response.

twilio.getMessage
ParameterTypeRequiredDescription
inputstringNoInput parameter

makeCall

makeCall

Module: twilio | Returns: object -- API response.

twilio.makeCall
ParameterTypeRequiredDescription
inputstringNoInput parameter

listCalls

listCalls

Module: twilio | Returns: object -- API response.

twilio.listCalls
ParameterTypeRequiredDescription
inputstringNoInput parameter

getCall

getCall

Module: twilio | Returns: object -- API response.

twilio.getCall
ParameterTypeRequiredDescription
inputstringNoInput parameter

listPhoneNumbers

listPhoneNumbers

Module: twilio | Returns: object -- API response.

twilio.listPhoneNumbers
ParameterTypeRequiredDescription
inputstringNoInput parameter

lookupPhoneNumber

lookupPhoneNumber

Module: twilio | Returns: object -- API response.

twilio.lookupPhoneNumber
ParameterTypeRequiredDescription
inputstringNoInput parameter

createVerifyService

createVerifyService

Module: twilio | Returns: object -- API response.

twilio.createVerifyService
ParameterTypeRequiredDescription
inputstringNoInput parameter

sendVerification

sendVerification

Module: twilio | Returns: object -- API response.

twilio.sendVerification
ParameterTypeRequiredDescription
inputstringNoInput parameter

checkVerification

checkVerification

Module: twilio | Returns: object -- API response.

twilio.checkVerification
ParameterTypeRequiredDescription
inputstringNoInput parameter

listConversations

listConversations

Module: twilio | Returns: object -- API response.

twilio.listConversations
ParameterTypeRequiredDescription
inputstringNoInput parameter

createConversation

createConversation

Module: twilio | Returns: object -- API response.

twilio.createConversation
ParameterTypeRequiredDescription
inputstringNoInput parameter

addParticipant

addParticipant

Module: twilio | Returns: object -- API response.

twilio.addParticipant
ParameterTypeRequiredDescription
inputstringNoInput parameter

sendConversationMessage

sendConversationMessage

Module: twilio | Returns: object -- API response.

twilio.sendConversationMessage
ParameterTypeRequiredDescription
inputstringNoInput parameter

getAccountInfo

getAccountInfo

Module: twilio | Returns: object -- API response.

twilio.getAccountInfo
ParameterTypeRequiredDescription
inputstringNoInput parameter

deleteMessage

deleteMessage

Module: twilio | Returns: object -- API response.

twilio.deleteMessage
ParameterTypeRequiredDescription
inputstringNoInput parameter

Error Handling

All functions throw on failure. Common errors:

ErrorCause
Twilio API error (${res.status}): ${t}Check the error message for details
twilio.setCredentials requires accountSid, authToken.Check the error message for details
twilio.deleteMessage requires an ID.Check the error message for details
Twilio: "..." not configured. Call twilio.setCredentials first.Check the error message for details
@desc "Send sms and validate result"
do
  set $result as twilio.sendSms
  if $result != null
    print "Success"
  else
    print "No result"
  end
enddo

Recipes

1. List and iterate Messages

Retrieve all items and loop through them.

@desc "Setup authentication"
do
  twilio.setCredentials $token
enddo

@desc "List messages and iterate results"
do
  set $result as twilio.listMessages
  each $item in $result
    print $item
  end
enddo

2. Create a new item with sendSms

Create a new resource and capture the result.

@desc "Setup authentication"
do
  twilio.setCredentials $token
enddo

@desc "Send sms"
do
  set $result as twilio.sendSms
  print "Created: " + $result
enddo

3. Check before creating

List existing items and only create if needed.

@desc "Setup authentication"
do
  twilio.setCredentials $token
enddo

@desc "List messages and send sms"
do
  set $existing as twilio.listMessages
  if $existing == null
    twilio.sendSms
    print "Item created"
  else
    print "Item already exists"
  end
enddo

4. Multi-step Twilio workflow

Chain multiple twilio operations together.

@desc "Setup authentication"
do
  twilio.setCredentials $token
enddo

@desc "Send sms, send mms, and more"
do
  set $r_sendSms as twilio.sendSms
  set $r_sendMms as twilio.sendMms
  set $r_listMessages as twilio.listMessages
  print "All operations complete"
enddo

5. Safe sendSms with validation

Check results before proceeding.

@desc "Setup authentication"
do
  twilio.setCredentials $token
enddo

@desc "Send sms and validate result"
do
  set $result as twilio.sendSms
  if $result != null
    print "Success: " + $result
  else
    print "Operation returned no data"
  end
enddo

Related Modules

  • json -- JSON module for complementary functionality

Versions (1)

VersionTagPublished
0.1.1latest1 months ago
Install
$ robinpath add @robinpath/twilio

Collaborators

Dumitru Balaban
Dumitru Balaban
@dumitru
View all @robinpath modules
Version0.1.1
LicenseMIT
Unpacked Size4.7 KB
Versions1
Weekly Downloads21
Total Downloads21
Stars0
Last Publish1 months ago
Created1 months ago

Category

utilities