Skip to content

An example Turn.io UI integration on Replit. This extends the Turn UI with a quick reply, custom profile information, and action menus.

Notifications You must be signed in to change notification settings

turnhub/turnio-integration-replit

Repository files navigation

turnio-integration-replit

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:

  1. 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
  2. You have gone through the DuckDuckGo suggested reply example and are comfortable with how to set up a Custom Integration in Turn.

How to run this

Running on Replit

Run on Repl.it

  1. Click the Run on Repl.it button above and install this example into your Repl.it workspace.
  2. Get a Turn token and add it as a secret called TOKEN in Repl.it
  3. Sign-up for a free Giphy developer API account and obtain an API token, add that as a secret called GIPHY_API_KEY in Repl.it
  4. (Optional) If you're using a custom Turn API URL, set it as a secret called TURN_API_URL (defaults to https://whatsapp.turn.io)
  5. 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.
  6. Send a message to your number and interact with the UI!

Running locally

  1. Clone this repository

  2. Install dependencies: poetry install

  3. 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
  4. Run the application: python main.py

  5. 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:

screenshot1

Here's a screenshot showing the Giphy menu when a message contains the word gif:

screenshot2

About

An example Turn.io UI integration on Replit. This extends the Turn UI with a quick reply, custom profile information, and action menus.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages