Skip to content

Instantly share code, notes, and snippets.

@itskhanow
Last active April 9, 2024 23:11
Show Gist options
  • Save itskhanow/423f0ae6298b7779f587621612dc3f83 to your computer and use it in GitHub Desktop.
Save itskhanow/423f0ae6298b7779f587621612dc3f83 to your computer and use it in GitHub Desktop.
Twilio Voice Client Store

Twilio Voice

Twilio Account Setup

In order to authorize with Twilio Voice certain SIDs and API keys and secrets need to be set for the domain. The JSON object for this is of the form:

"khanchat.onetechnology.com": {
  "accountSid": "ACda6d0dc86c5d8e4f9bc38d2c65cb7068",
  "twimlAppSid": "AP790b21f8cedcbfd9d389e92b66939916",
  "apiKey": "SK74f0e340cb54587726b8a31c8f0e9725",
  "apiSecret": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "callerId": "+18446310364"
}

First, make note of your account SID in the Twilio Console.

Next, create a TwiML App. A TwiML Application can be created in the TwiML Application Console.

The Request URL of the TwiML app should be set to https://twilio-backend.onetechnology.com/voice/[[[DOMAIN]]].

Grab the twimlAppSid

Finally, set the phone number to use the TwiML App that we've created.

If a different Twilio API Key should be used, it would need to be created at Create API Key and the values of apiKey and apiSecret should be set to the newly created SID and secret.

Store Actions

"Init Twilio Voice"

initTwilioVoice()

Initializes the Twilio Voice JS SDK and retrieves an access token to use when communicating with Twilio services. Will require a ONEplatform Bearer Token to be set with an app domain before running. In other words, the user should be logged in and able to run authenticated workflows before calling this.

"Twilio Outgoing Call"

twilioOutgoingCall(toNumber: string, fromNumber: string)

Attempts to make an outgoing call to toNumber with caller ID set as fromNumber. Accepts phone numbers in the form of +15551231234.

"Twilio Disconnect Call"

twilioDisconnectCall()

Disconnects the currently active call.

Action Triggers

  • onTwilioCallAccepted
  • onTwilioCallCancelled
  • onTwilioCallDisconnected
  • onTwilioCallRinging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment