Skip to content

Issue converting from legacy template to ContentTemplate #845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JamesCThompson opened this issue Mar 27, 2025 · 2 comments
Open

Issue converting from legacy template to ContentTemplate #845

JamesCThompson opened this issue Mar 27, 2025 · 2 comments
Labels
priority: high Needs immediate attention; blockers or critical

Comments

@JamesCThompson
Copy link

JamesCThompson commented Mar 27, 2025

Issue Summary

I have been using the SDK to send messages for several years using the now legacy way of providing the contents in the body:

public String sendTextMessage( final String sender, final String receiver, final String body ) {

    PhoneNumber from = new PhoneNumber( "whatsapp:" + sender );
    PhoneNumber to = new PhoneNumber( "whatsapp:" + receiver );

    return Message._creator_( to, from, body )
        .setStatusCallback( callBackUrl )
        .create()
        .getSid();
}

The contents has matched templates that were uploaded to Twilio with placeholders but we had been resolving those placeholders before creating the message.

I have converted the templates through the Twilio UI as per the Upgrading WhatsApp Templates to Content Templates article on the support site.

Following that I have changed the method of send to:

public String sendTextMessage( final String sender, final String receiver, final String contentSid, final Map<String, String> replacements ) {
    
    PhoneNumber from = new PhoneNumber( "whatsapp:" + sender );
    PhoneNumber to = new PhoneNumber( "whatsapp:" + receiver );

    return Message.creator( to, from, contentSid )
        .setContentSid( contentSID ) 
        .setContentVariables( new JSONObject( replacements ).toString() )
        .setStatusCallback( callBackUrl )
        .create()
        .getSid();
}

As per the guide on Send Messages with a Content Template

However I now get com.twilio.exception.ApiException: Twilio could not find a Channel with the specified From address however none of my sender details have changed.

what am I missing in order to update to use the contentSid and continue sending messages from the 1st April?

Technical details:

twilio-java version: 10.6.0
java version: 11

@JamesCThompson
Copy link
Author

I should add that I have looked through the docs on the help centre and none of them reference their being any change to the account or senders following the template change.

I can confirm that the sender details are correct as I can run a version of the service using the old payload with the same account & sender configuration.

@sbansla sbansla added priority: high Needs immediate attention; blockers or critical and removed priority: high Needs immediate attention; blockers or critical labels Apr 7, 2025
@manisha1997
Copy link
Contributor

@JamesCThompson , Thanks for raising the issue. We will resolve this as soon as possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high Needs immediate attention; blockers or critical
Projects
None yet
Development

No branches or pull requests

3 participants