Issue converting from legacy template to ContentTemplate
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 527
- Forks
- 453
- Avg merge
- 10h 59m
- Merged PRs (30d)
- 6
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Message.creator and Message.creator entry points shown in the report, then review the linked content-template sending guide and compare the legacy and migrated calls. Reproduce the Channel error with twilio-java 10.6.0 on Java 11; done means the migration behavior is explained or an SDK/API correction is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100