An example Turn.io UI integration on Replit. This will augment the Turn UI with custom profile information, a suggested reply, and a custom action menu.
This Replit assumes the following:
- You have gone through the webhooks example and are comfortable with how to get an authentication for Turn and set it up as a secret in Repl.it
- You have gone through the DuckDuckGo suggested reply example and are comfortable with how to set up a
Custom Integrationin Turn.
- Click the
Run on Repl.itbutton above and install this example into your Repl.it workspace. - Get a Turn token and add it as a secret called
TOKENin Repl.it - Sign-up for a free Giphy developer API account and obtain an API token, add that as a secret called
GIPHY_API_KEYin Repl.it - (Optional) If you're using a custom Turn API URL, set it as a secret called
TURN_API_URL(defaults tohttps://whatsapp.turn.io) - Set up the custom integration using the URL generated for your workspace by Repl.it. We don't use authentication for this example, so choose either HTTP auth types from the dropdown and write something random in the token field.
- Send a message to your number and interact with the UI!
-
Clone this repository
-
Install dependencies:
poetry install -
Set environment variables:
export TOKEN="your-turn-api-token" export GIPHY_API_KEY="your-giphy-api-key" export TURN_API_URL="https://whatsapp.turn.io" # Optional export REPLIT_DEV_DOMAIN="localhost:5000" # For local development
-
Run the application:
python main.py -
The server will start on
http://0.0.0.0:5000
The Roll 🎲 menu has two options, both of those hit a custom URL in this Repl.it, pick a random number between 1 and 6 and send the result back as a reply.
The Auto Giphy ⚡️ menu will search Giphy for a gif matching the text of the message. We will then send the Gif back as an MP4 video as WhatsApp doesn't support gif natively in the API at the moment.
Here's a screenshot showing the custom profile addition, the suggested reply, and the roll a dice action menu:
Here's a screenshot showing the Giphy menu when a message contains the word gif:

