eliza icon indicating copy to clipboard operation
eliza copied to clipboard

feat: add twilio plugin implementation Closes #1631

Open boolkeys opened this issue 11 months ago • 14 comments

feat: add twilio plugin implementation

Relates to & Closes #1631

Risks

Low - This plugin:

  • Uses standard Twilio services (SMS, Voice with Amazon Polly TTS)
  • Implements proper webhook handling and security
  • Includes comprehensive error handling and logging
  • Follows A2P 10DLC compliance requirements

Background

What does this PR do?

  • Adds Twilio plugin for SMS and voice interactions
  • Implements two core actions: SEND_SMS and CALL_VOICE
  • Supports custom Amazon Polly voices
  • Provides webhook server for handling incoming messages/calls
  • Includes TypeScript types and interfaces
  • Follows Eliza plugin architecture

What kind of change is this?

Feature (non-breaking change which adds functionality)

Documentation

Added comprehensive documentation including:

  • A2P 10DLC compliance requirements
  • Plugin configuration guide
  • Available actions and usage examples
  • Voice configuration options
  • Webhook setup instructions (ngrok & production)
  • Environment variables reference
  • Troubleshooting guide

Testing

Where should a reviewer start?

  1. src/actions/ - SMS and voice call actions
  2. src/services/webhook.ts - Webhook handling
  3. src/services/twilio.ts - Twilio service implementation

Testing steps

  1. Configure environment:

    ANTHROPIC_API_KEY=your_key
    TWILIO_ACCOUNT_SID=your_sid
    TWILIO_AUTH_TOKEN=your_token
    TWILIO_PHONE_NUMBER=your_number
    TWILIO_CHARACTER=your_character.json
    WEBHOOK_PORT=3004
    WEBHOOK_BASE_URL=your_webhook_url
    
  2. Setup webhook:

    • Development: Use ngrok (ngrok http 3004)
    • Production: Configure domain
  3. Test SMS action:

    "Send SMS to +1234567890: Hello!"
    
  4. Test Voice action:

    "Call +1234567890 and say Welcome!"
    

Voice Configuration Testing

Test different voice configurations:

{
	"settings": {
		"voice": {
			"language": "en",
			"gender": "female"
		}
	}
}

Or with custom Polly voice:

{
	"settings": {
		"voice": {
		"custom": "Polly.Aria-Neural"
		}
	}
}

Video demo

https://www.boolkeys.com/eliza/plugin-twilio/DEMO-plugin-twilio.mov

Deploy Notes

  1. Register for A2P 10DLC if sending to US numbers
  2. Configure webhooks in Twilio Console
  3. Set all required environment variables
  4. Ensure webhook endpoint is publicly accessible

Discord: @boolkeys

boolkeys avatar Jan 10 '25 23:01 boolkeys

@Freytes core workflow ok: User calls or texts Twilio number -> agent responses via text or voice.

current code doesn't need ElevenLabs or Deepgram services. using Twilio's built-in services: voice generation and speech recognition.

boolkeys avatar Jan 11 '25 00:01 boolkeys

@Freytes core workflow ok: User calls or texts Twilio number -> agent responses via text or voice.

current code doesn't need ElevenLabs or Deepgram services. using Twilio's built-in services: voice generation and speech recognition.

If I can get a demo of this working I would recommend that you completed the bounty

Freytes avatar Jan 11 '25 00:01 Freytes

@Freytes core workflow ok: User calls or texts Twilio number -> agent responses via text or voice. current code doesn't need ElevenLabs or Deepgram services. using Twilio's built-in services: voice generation and speech recognition.

If I can get a demo of this working I would recommend that you completed the bounty

Hi, demo is here: https://www.boolkeys.com/eliza/plugin-twilio/DEMO-plugin-twilio.mov how can I complete the bounty? thanks for your help

boolkeys avatar Jan 11 '25 07:01 boolkeys

@Freytes core workflow ok: User calls or texts Twilio number -> agent responses via text or voice. current code doesn't need ElevenLabs or Deepgram services. using Twilio's built-in services: voice generation and speech recognition.

If I can get a demo of this working I would recommend that you completed the bounty

Hi, demo is here: https://www.boolkeys.com/eliza/plugin-twilio/DEMO-plugin-twilio.mov how can I complete the bounty? thanks for your help

@boolkeys great demo! Jin will be in touch for bounty payment

Freytes avatar Jan 11 '25 07:01 Freytes

would like to mention that this plugin does not seem functional... i cant find the code for the actions?

mot1se avatar Jan 11 '25 08:01 mot1se

would like to mention that this plugin does not seem functional... i cant find the code for the actions?

no action needed, all code is triggered via webhook need to setup a server webhook (like ngrok) and configure that webhook url in twilio console before using

boolkeys avatar Jan 11 '25 10:01 boolkeys

You can add a service and avoid the ngrok. Also the actions should be implemented since is a framework and people will use your tool as building block.

AIFlowML avatar Jan 12 '25 13:01 AIFlowML

You can add a service and avoid the ngrok. Also the actions should be implemented since is a framework and people will use your tool as building block.

Sure I’ll look into that

boolkeys avatar Jan 13 '25 17:01 boolkeys

@boolkeys is it probable to use a custom voice if support by Twilio?

Freytes avatar Jan 13 '25 23:01 Freytes

@boolkeys is it probable to use a custom voice if support by Twilio?

Yes, Twilio supports custom voices through Amazon Polly. https://docs.aws.amazon.com/polly/latest/dg/available-voices.html

I updated the code to support custom Polly voices. Read more in README

boolkeys avatar Jan 13 '25 23:01 boolkeys

You can add a service and avoid the ngrok. Also the actions should be implemented since is a framework and people will use your tool as building block.

2 options for the webhook: ngrok for local (https needed by twilio) or custom domain name). I added 2 actions: SEND_SMS and CALL_VOICE

boolkeys avatar Jan 13 '25 23:01 boolkeys

@boolkeys I thought Twilio has an automatic ElevenLabs integration, I am just thinking of other options aside from Amazon

Freytes avatar Jan 14 '25 00:01 Freytes

@boolkeys I thought Twilio has an automatic ElevenLabs integration, I am just thinking of other options aside from Amazon

I will integrate elevenlabs as an option (Amazon does not require api key)

boolkeys avatar Jan 14 '25 17:01 boolkeys

@boolkeys I thought Twilio has an automatic ElevenLabs integration, I am just thinking of other options aside from Amazon

I will integrate elevenlabs as an option (Amazon does not require api key)

Can we discuss? Please reach out to me on discord, I have reached out to you

Freytes avatar Jan 14 '25 17:01 Freytes

plugin-twilio updated with:

  • elevenlabs integration
  • sms and call actions

feel free to test it out and get back to me with any question/inquiry @Freytes @mot1se

boolkeys avatar Jan 17 '25 00:01 boolkeys

I have tested everything and reviewed your code. Everything seems to be in order, and it's ready to proceed to the main branch.

GeorgeBacky avatar Jan 17 '25 09:01 GeorgeBacky

I have tested everything and reviewed your code. Everything seems to be in order, and it's ready to proceed to the main branch.

great! did you enjoy the experience? kind of fun talking to our made-up characters by phone, right?

boolkeys avatar Jan 17 '25 11:01 boolkeys

[!IMPORTANT]

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces a comprehensive Twilio plugin for ElizaOS, enabling SMS and voice call capabilities. The implementation includes services for sending SMS, handling voice calls, text-to-speech conversion using ElevenLabs, and webhook management. The plugin supports initializing calls, generating responses, and managing conversation memory across different interaction types.

Changes

File Change Summary
.gitignore Added .env_BACKUP, pnpm-lock.yaml, and /characters to ignored files
package.json Added @elizaos/plugin-twilio dependency
packages/core/types/index.d.ts Added ServiceType enum
packages/plugin-twilio/ Added complete plugin structure with services, actions, routes, and utilities

Assessment against linked issues

Objective Addressed Explanation
Twilio text support
Twilio voice support
ElevenLabs TTS integration
Speech-to-Text No explicit Deepgram/Whisper integration visible
Demonstration of functionality Video recording not included in PR

The pull request substantially meets the core requirements for Twilio text and voice integration, with a robust implementation of SMS and voice call capabilities. The ElevenLabs integration for text-to-speech is well-implemented. However, the speech-to-text component and video demonstration are not explicitly addressed in the current PR.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jan 18 '25 14:01 coderabbitai[bot]

Speech-to-Text ❓ No explicit Deepgram/Whisper integration visible Demonstration of functionality ❓ Video recording not included in PR

The pull request substantially meets the core requirements for Twilio text and voice integration, with a robust implementation of SMS and voice call capabilities. The ElevenLabs integration for text-to-speech is well-implemented. However, the speech-to-text component and video demonstration are not explicitly addressed in the current PR.


This plugin uses Twilio's built-in speech recognition capabilities for voice interactions.

Demo here: https://www.boolkeys.com/eliza/plugin-twilio/DEMO-plugin-twilio.mov

boolkeys avatar Jan 21 '25 16:01 boolkeys

@boolkeys how can we use your plugin? Is there anything else to do for the integration? I am happy to contribute as well.

https://github.com/elizaOS/eliza/issues/1631#issuecomment-2664964453

sebastienmascha avatar Feb 18 '25 18:02 sebastienmascha

You can download pr and use the plugin as is but i don't know about integration in Eliza plugins, i guess i have to make a new pr since the plugin repo exists now

boolkeys avatar Feb 18 '25 18:02 boolkeys

plugin reference in registry "@elizaos-plugins/plugin-twilio": "github:boolkeys/plugin-twilio"

https://github.com/boolkeys/plugin-twilio

boolkeys avatar Feb 24 '25 23:02 boolkeys