Multiple API Endpoints

How do I hit both Clerk API endpoint as well as my own application in Twilio?

Some clients who are on the API plan require to hit both Clerk endpoint as well as their internal application. There are multiple ways this can be achieved, but in this tutorial, we will be covering Twilio Studio.

As an example, we will be hitting Clerk API endpoint as well as Front App.

Navigate to Twilio Studio and create a new flow. When designing your flow select Make HTTP Requst Widget. Here is an example of the flow:

Clerk

Clerk API requires the following parameters to be set in order to work properly.

Request URL: https://api.clerk.chat/prod/twilio/events

HTTP Parameters:

To: {{trigger.message.To}}
From: {{trigger.message.From}}
Body: {{trigger.message.Body}}

FrontApp

Request URL: https://webhook.frontapp.com/sms/*********

Request Body:

{
"SmsSid": "{{trigger.message.MessageSid}}",
"SmsMessageSid": "{{trigger.message.MessageSid}}",
"ToState": "{{trigger.message.ToState}}",
"From": "{{trigger.message.From}}",
"MessageSid": "{{trigger.message.MessageSid}}",
"AccountSid": "{{trigger.message.AccountSid}}",
"ToCity": "{{trigger.message.ToCity}}",
"FromCountry": "{{trigger.message.FromCountry}}",
"ToZip": "{{trigger.message.ToZip}}",
"FromCity": "{{trigger.message.FromCity}}",
"To": "{{trigger.message.To}}",
"FromZip": "{{trigger.message.FromZip}}",
"ToCountry": "{{trigger.message.ToCountry}}",
"Body": "{{trigger.message.Body}}",
"NumMedia": "{{trigger.message.NumMedia}}",
"FromState": "{{trigger.message.FromState}}"
}

Here is an example of a Twilio Studio Flow JSON that you can import into your flow.

  • Anytime someone messages your number it will appear in both Clerk and in Front

  • Any outbound messages sent from Clerk will only be imported into Front after a new inbound message is received in the conversation. This is a Front limitation (refer to their docs).