We intend to sunset the Programmable Chat API on July 25, 2022 to focus on the next generation of chat: the Twilio Conversations API. Find out about the EOL process. We have also prepared this Migration Guide to assist in the transition from Chat to Conversations.
Laravel implementation of Twilio Chat
-
Clone the repository and
cd
into it -
Install the application's dependencies with Composer
composer install
-
Copy the sample configuration file and edit it to match your configuration
cp .env.example .env
You can find your TWILIO_ACCOUNT_SID
in your
Twilio Account Settings.
You need to create an API key that will give you a TWILIO_API_KEY
and a
TWILIO_API_SECRET
. For that purpose click
here.
For TWILIO_CHAT_SERVICE_SID
you can click here,
where you must create a Programmable Chat Service. When the service is created you'll
have access to the service's SID.
-
Generate an
APP_KEY
php artisan key:generate
-
Run the application using Artisan
php artisan serve
Now you can access the application at http://localhost:8000
.
If you want your chat application to be reachable publicly in the internet, you can use a service like ngrok.
-
Expose the application to the wider Internet
ngrok http 8000
It is artisan serve
default behavior to use http://localhost:8000
when
running the application. This means that the ip addresses where your app will be
reachable on you local machine will vary depending on the operating system.
The most common scenario, is that your app will be reachable through address
http://127.0.0.1:8000
, and this is important because ngrok creates the
tunnel using only that address. So, if http://127.0.0.1:8000
is not reachable
in your local machine when you run the app, you must tell artisan to use an
address, like this:
php artisan serve --host=127.0.0.1
This application uses this Twilio helper library
-
Run at the top-level directory
vendor/bin/phpunit
If you don't have phpunit installed on your system, you can follow these instructions to install it.
-
Run javascript tests
cd public && npm install && npm test