Skip to content

Issue converting from legacy template to ContentTemplate #845

Open
@JamesCThompson

Description

@JamesCThompson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: highNeeds immediate attention; blockers or critical

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions